Source Code Cross Referenced for ServerEnvTable.java in  » Net » Terracotta » com » tc » servers » 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 » Net » Terracotta » com.tc.servers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.servers;
005:
006:        import org.dijon.Button;
007:        import org.dijon.Container;
008:        import org.dijon.TextField;
009:
010:        import com.tc.admin.common.XCellEditor;
011:        import com.tc.admin.common.XObjectTable;
012:        import com.tc.admin.common.XTableCellRenderer;
013:        import com.tc.admin.common.XTextField;
014:
015:        import java.awt.BorderLayout;
016:        import java.awt.Color;
017:        import java.awt.Insets;
018:        import java.awt.event.ActionEvent;
019:        import java.awt.event.ActionListener;
020:        import java.io.File;
021:
022:        import javax.swing.JComponent;
023:        import javax.swing.JFileChooser;
024:        import javax.swing.JTable;
025:        import javax.swing.UIManager;
026:        import javax.swing.border.Border;
027:        import javax.swing.border.EmptyBorder;
028:        import javax.swing.table.TableCellEditor;
029:        import javax.swing.table.TableCellRenderer;
030:
031:        public class ServerEnvTable extends XObjectTable {
032:            private TableCellRenderer m_renderer;
033:            private TableCellEditor m_editor;
034:            private JFileChooser m_chsr;
035:            private File m_lastDir;
036:
037:            protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
038:
039:            public ServerEnvTable() {
040:                super ();
041:            }
042:
043:            public TableCellRenderer getCellRenderer(int row, int col) {
044:                if (col == 1) {
045:                    if (m_renderer == null) {
046:                        m_renderer = new ValueRenderer();
047:                    }
048:                    return m_renderer;
049:                }
050:                return super .getCellRenderer(row, col);
051:            }
052:
053:            public TableCellEditor getCellEditor(int row, int col) {
054:                if (col == 1) {
055:                    if (m_editor == null) {
056:                        m_editor = new ValueEditor();
057:                    }
058:                    return m_editor;
059:                }
060:                return super .getCellEditor(row, col);
061:            }
062:
063:            class ValueRenderer extends XTableCellRenderer {
064:                protected TableCellEditor m_rendererDelegate;
065:
066:                public ValueRenderer() {
067:                    super ();
068:                    m_rendererDelegate = createCellEditor();
069:                }
070:
071:                protected TableCellEditor createCellEditor() {
072:                    return new ValueEditor(true);
073:                }
074:
075:                public java.awt.Component getTableCellRendererComponent(
076:                        JTable table, Object value, boolean isSelected,
077:                        boolean hasFocus, int row, int col) {
078:                    JComponent c = (JComponent) m_rendererDelegate
079:                            .getTableCellEditorComponent(table, value,
080:                                    isSelected, row, col);
081:
082:                    c
083:                            .setBorder(hasFocus ? UIManager
084:                                    .getBorder("Table.focusCellHighlightBorder")
085:                                    : null);
086:
087:                    return c;
088:                }
089:            }
090:
091:            class ChooserButton extends Button {
092:                int m_row, m_col;
093:
094:                ChooserButton(String text) {
095:                    super (text);
096:                    setMargin(new Insets(0, 2, 0, 2));
097:                }
098:
099:                void setCell(int row, int col) {
100:                    m_row = row;
101:                    m_col = col;
102:                }
103:
104:                int getRow() {
105:                    return m_row;
106:                }
107:
108:                int getCol() {
109:                    return m_col;
110:                }
111:            }
112:
113:            private JFileChooser getChooser() {
114:                if (m_chsr == null) {
115:                    m_chsr = new JFileChooser();
116:                    m_chsr.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
117:                }
118:
119:                if (m_lastDir != null) {
120:                    m_chsr.setCurrentDirectory(m_lastDir);
121:                }
122:
123:                return m_chsr;
124:            }
125:
126:            class ValueEditor extends XCellEditor {
127:                ChooserButton m_chsrButton;
128:                XTextField m_valueField;
129:                boolean m_isRenderer;
130:
131:                ValueEditor() {
132:                    this (false);
133:                }
134:
135:                ValueEditor(boolean isRenderer) {
136:                    super (new XTextField());
137:
138:                    m_isRenderer = isRenderer;
139:
140:                    m_valueField = (XTextField) m_editorComponent;
141:                    m_valueField.addActionListener(new ActionListener() {
142:                        public void actionPerformed(ActionEvent ae) {
143:                            int row = m_chsrButton.getRow();
144:                            int col = m_chsrButton.getCol();
145:
146:                            getServerPropertyAt(row).setValue(
147:                                    m_valueField.getText());
148:                            getServerEnvTableModel().fireTableCellUpdated(row,
149:                                    col);
150:                        }
151:                    });
152:                    m_valueField.setMargin(new Insets(0, 0, 0, 0));
153:
154:                    m_chsrButton = new ChooserButton("...");
155:                    m_chsrButton.addActionListener(new ActionListener() {
156:                        public void actionPerformed(ActionEvent ae) {
157:                            JFileChooser chsr = getChooser();
158:
159:                            if (chsr.showOpenDialog(ServerEnvTable.this ) == JFileChooser.APPROVE_OPTION) {
160:                                int row = m_chsrButton.getRow();
161:                                int col = m_chsrButton.getCol();
162:                                String path = chsr.getSelectedFile()
163:                                        .getAbsolutePath();
164:
165:                                removeEditor();
166:                                getServerEnvTableModel().setValueAt(path, row,
167:                                        col);
168:                            } else {
169:                                removeEditor();
170:                            }
171:                            m_lastDir = chsr.getCurrentDirectory();
172:                        }
173:                    });
174:
175:                    m_editorComponent = new PropertyValuePanel(m_valueField,
176:                            m_chsrButton);
177:                    m_clicksToStart = 1;
178:                }
179:
180:                public java.awt.Component getTableCellEditorComponent(
181:                        JTable table, Object value, boolean isSelected,
182:                        int row, int col) {
183:                    Color fg = isSelected ? table.getSelectionForeground()
184:                            : table.getForeground();
185:                    Color bg = isSelected ? table.getSelectionBackground()
186:                            : table.getBackground();
187:
188:                    ServerProperty prop = getServerPropertyAt(row);
189:
190:                    m_chsrButton.setCell(row, col);
191:                    m_chsrButton.setForeground(table.getForeground());
192:                    m_chsrButton.setBackground(table.getBackground());
193:                    m_chsrButton.setFont(table.getFont());
194:
195:                    m_valueField.setText(prop.getValue());
196:                    if (!m_isRenderer) {
197:                        m_valueField.setForeground(UIManager
198:                                .getColor("TextField.foreground"));
199:                        m_valueField.setBackground(UIManager
200:                                .getColor("TextField.background"));
201:                    } else {
202:                        m_valueField.setForeground(fg);
203:                        m_valueField.setBackground(bg);
204:                    }
205:                    m_valueField.setFont(table.getFont());
206:
207:                    if (!m_isRenderer) {
208:                        m_valueField.setBorder(UIManager
209:                                .getBorder("Table.focusCellHighlightBorder"));
210:                    } else {
211:                        m_valueField.setBorder(noFocusBorder);
212:                        m_chsrButton.setVisible(false);
213:                    }
214:
215:                    return (java.awt.Component) m_editorComponent;
216:                }
217:            }
218:
219:            public ServerEnvTableModel getServerEnvTableModel() {
220:                return (ServerEnvTableModel) getModel();
221:            }
222:
223:            public ServerProperty getServerPropertyAt(int row) {
224:                return getServerEnvTableModel().getServerPropertyAt(row);
225:            }
226:        }
227:
228:        class PropertyValuePanel extends Container {
229:            PropertyValuePanel(TextField textfield, Button button) {
230:                super ();
231:                setLayout(new BorderLayout());
232:                add(textfield);
233:                add(button, BorderLayout.EAST);
234:                setBorder(null);
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.