Source Code Cross Referenced for ProcessListTab.java in  » Database-Client » squirrel-sql-2.6.5a » de » ixdb » squirrel_sql » plugins » cache » 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 » Database Client » squirrel sql 2.6.5a » de.ixdb.squirrel_sql.plugins.cache 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.ixdb.squirrel_sql.plugins.cache;
002:
003:        import net.sourceforge.squirrel_sql.client.session.ISession;
004:        import net.sourceforge.squirrel_sql.client.session.mainpanel.IMainPanelTab;
005:        import net.sourceforge.squirrel_sql.fw.gui.ButtonTableHeader;
006:        import net.sourceforge.squirrel_sql.fw.gui.SortableTableModel;
007:        import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerTablePanel;
008:        import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
009:        import net.sourceforge.squirrel_sql.fw.datasetviewer.CellDataPopup;
010:
011:        import javax.swing.*;
012:        import javax.swing.table.*;
013:        import java.awt.*;
014:        import java.awt.event.ActionEvent;
015:        import java.awt.event.ActionListener;
016:        import java.awt.event.MouseAdapter;
017:        import java.awt.event.MouseEvent;
018:
019:        public class ProcessListTab implements  IMainPanelTab {
020:            ProcessListPanel _pnlProcessList;
021:            private ISession _session;
022:            private ProcessData[] _procData;
023:            private ProcessListTabListener _processListTabListener;
024:
025:            public ProcessListTab(ProcessData[] procData,
026:                    ProcessListTabListener processListTabListener) {
027:                _procData = procData;
028:
029:                _processListTabListener = processListTabListener;
030:                _pnlProcessList = new ProcessListPanel();
031:
032:                DefaultTableModel dtm = new DefaultTableModel() {
033:                    public boolean isCellEditable(int row, int column) {
034:                        return false;
035:                    }
036:
037:                    public Object getValueAt(int row, int column) {
038:                        return onGetValueAt(row, column);
039:                    }
040:
041:                    public String getColumnName(int column) {
042:                        return ProcessData.getColumns()[column];
043:                    }
044:
045:                    public int getRowCount() {
046:                        if (null == ProcessListTab.this ) {
047:                            // I have seen the reference to the outer class being null
048:                            // when this method is called.
049:                            // I have seen it only with the runtime jars
050:                            // and on Linux.
051:                            // I could not reproduce in my IDE.
052:                            return 0;
053:                        } else {
054:                            return ProcessListTab.this ._procData.length;
055:                        }
056:                    }
057:
058:                    public int getColumnCount() {
059:                        return ProcessData.getColumns().length;
060:                    }
061:
062:                };
063:
064:                SortableTableModel stm = (SortableTableModel) _pnlProcessList.tblProcessList
065:                        .getModel();
066:                stm.setActualModel(dtm);
067:
068:                DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() {
069:                    public Component getTableCellRendererComponent(
070:                            JTable table, Object value, boolean isSelected,
071:                            boolean hasFocus, int row, int column) {
072:                        Component rend = super 
073:                                .getTableCellRendererComponent(table, value,
074:                                        isSelected, hasFocus, row, column);
075:                        if (null != value && 0 < value.toString().indexOf('\n')) {
076:                            rend.setBackground(Color.cyan);
077:                        } else {
078:                            if (isSelected) {
079:                                setBackground(table.getSelectionBackground());
080:                            } else {
081:                                setBackground(table.getBackground());
082:                            }
083:                        }
084:                        return rend;
085:                    }
086:                };
087:
088:                final TableColumnModel tcm = new DefaultTableColumnModel();
089:                for (int i = 0; i < ProcessData.getColumns().length; ++i) {
090:                    final TableColumn col = new TableColumn(i);
091:                    col.setHeaderValue(ProcessData.getColumns()[i]);
092:                    col.setCellRenderer(dtcr);
093:                    tcm.addColumn(col);
094:                }
095:
096:                _pnlProcessList.tblProcessList.setColumnModel(tcm);
097:
098:                _pnlProcessList.btnRefresh
099:                        .addActionListener(new ActionListener() {
100:                            public void actionPerformed(ActionEvent e) {
101:                                onRefresh();
102:                            }
103:                        });
104:
105:                _pnlProcessList.btnTerminate
106:                        .addActionListener(new ActionListener() {
107:                            public void actionPerformed(ActionEvent e) {
108:                                onTerminate();
109:                            }
110:                        });
111:
112:                _pnlProcessList.btnClose
113:                        .addActionListener(new ActionListener() {
114:                            public void actionPerformed(ActionEvent e) {
115:                                onClose();
116:                            }
117:                        });
118:
119:                _pnlProcessList.tblProcessList
120:                        .addMouseListener(new MouseAdapter() {
121:                            public void mousePressed(MouseEvent evt) {
122:                                if (evt.getClickCount() == 2) {
123:                                    // figure out which column the user clicked on
124:                                    // so we can pass in the right column description
125:
126:                                    Point pt = evt.getPoint();
127:                                    int col = _pnlProcessList.tblProcessList
128:                                            .columnAtPoint(pt);
129:                                    ColumnDisplayDefinition dumDef = new ColumnDisplayDefinition(
130:                                            50, "Detail");
131:                                    CellDataPopup.showDialog(
132:                                            _pnlProcessList.tblProcessList,
133:                                            dumDef, evt, false);
134:                                }
135:                            }
136:                        });
137:            }
138:
139:            private void onClose() {
140:                _processListTabListener.closeRequested(_session);
141:            }
142:
143:            private void onTerminate() {
144:                int selectedRow = _pnlProcessList.tblProcessList
145:                        .getSelectedRow();
146:                selectedRow = _pnlProcessList.tblProcessList
147:                        .getSortableTableModel().transfromToModelRow(
148:                                selectedRow);
149:
150:                String msg;
151:                if (-1 == selectedRow) {
152:                    msg = "No process selected.\nPlease select the Process you wish to terminate.";
153:                    JOptionPane.showMessageDialog(_session.getApplication()
154:                            .getMainFrame(), msg);
155:                    return;
156:                }
157:
158:                msg = "Do you really wish to terminate the selected process?";
159:                if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(
160:                        _session.getApplication().getMainFrame(), msg,
161:                        "Terminate process", JOptionPane.YES_NO_CANCEL_OPTION)) {
162:                    return;
163:                }
164:
165:                int termRet = _processListTabListener.terminateRequested(
166:                        _session, _procData[selectedRow]);
167:
168:                if (1 != termRet) {
169:                    msg = "Terminate should return 1 but returned " + termRet
170:                            + ".\nMaybe terminate didn't succeed.";
171:                    JOptionPane.showMessageDialog(_session.getApplication()
172:                            .getMainFrame(), msg);
173:                    return;
174:                }
175:            }
176:
177:            private void onRefresh() {
178:                int selectedRow = _pnlProcessList.tblProcessList
179:                        .getSelectedRow();
180:
181:                ProcessData old = null;
182:                if (-1 != selectedRow) {
183:                    old = _procData[selectedRow];
184:                }
185:
186:                _procData = _processListTabListener.refreshRequested(_session);
187:
188:                SortableTableModel stm = (SortableTableModel) _pnlProcessList.tblProcessList
189:                        .getModel();
190:                ((DefaultTableModel) stm.getActualModel())
191:                        .fireTableDataChanged();
192:                stm.fireTableDataChanged();
193:
194:                ButtonTableHeader bth = (ButtonTableHeader) _pnlProcessList.tblProcessList
195:                        .getTableHeader();
196:
197:                if (-1 != bth.getCurrentlySortedColumnIdx()) {
198:                    stm.sortByColumn(bth.getCurrentlySortedColumnIdx(), bth
199:                            .isAscending());
200:                }
201:
202:                _pnlProcessList.tblProcessList.repaint();
203:
204:                if (null != old) {
205:                    for (int i = 0; i < _procData.length; i++) {
206:                        if (old.job == _procData[i].job) {
207:                            _pnlProcessList.tblProcessList.getSelectionModel()
208:                                    .setSelectionInterval(i, i);
209:                            break;
210:                        }
211:                    }
212:                }
213:
214:            }
215:
216:            private Object onGetValueAt(int row, int column) {
217:                try {
218:                    return ProcessData.class.getFields()[column]
219:                            .get(_procData[row]);
220:                } catch (IllegalAccessException e) {
221:                    throw new RuntimeException(e);
222:                }
223:            }
224:
225:            public String getTitle() {
226:                return "Processes";
227:            }
228:
229:            public String getHint() {
230:                return getTitle();
231:            }
232:
233:            public Component getComponent() {
234:                return _pnlProcessList;
235:            }
236:
237:            public void setSession(ISession session) {
238:                _session = session;
239:            }
240:
241:            public void sessionClosing(ISession session) {
242:                _session = null;
243:            }
244:
245:            public void select() {
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.