Source Code Cross Referenced for IExplorerService.java in  » Net » hyperpool-0.4.0 » vicazh » hyperpool » stream » net » http » 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 » hyperpool 0.4.0 » vicazh.hyperpool.stream.net.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package vicazh.hyperpool.stream.net.http;
002:
003:        import javax.swing.*;
004:        import javax.swing.tree.*;
005:        import javax.swing.text.*;
006:        import javax.swing.event.*;
007:        import org.jdesktop.jdic.desktop.*;
008:        import java.awt.event.*;
009:        import java.io.*;
010:        import java.net.*;
011:        import java.util.logging.*;
012:        import vicazh.hyperpool.stream.*;
013:        import vicazh.hyperpool.Start;
014:
015:        /**
016:         * The graphic explorer service
017:         * 
018:         * @author Victor Zhigunov
019:         * @version 0.4.0
020:         */
021:        public class IExplorerService extends IPeriodService implements 
022:                ExplorerServiceMBean, TreeSelectionListener, ActionListener,
023:                ListSelectionListener, TreeExpansionListener {
024:            private JTree tree;
025:
026:            private DefaultTreeModel model;
027:
028:            private IExplorerNode root;
029:
030:            private JTable table;
031:
032:            private IExplorerModel mFile;
033:
034:            private JButton buttonRefresh;
035:
036:            private JButton buttonOpen;
037:
038:            private JDialog dialog;
039:
040:            private JOptionPane optionPane;
041:
042:            private JTextField textDir;
043:
044:            private JFormattedTextField textSize;
045:
046:            private JFormattedTextField textMax;
047:
048:            /**
049:             * @param name
050:             *            service name
051:             * @param buttonClear
052:             *            clear button
053:             * @param dialogClear
054:             *            clear dialog
055:             * @param buttonStart
056:             *            start date range button
057:             * @param buttonEnd
058:             *            end date range button
059:             * @param box
060:             *            time period value combo box
061:             * @param dialogDate
062:             *            date select dialog
063:             * @param b1
064:             *            period radio button
065:             * @param b2
066:             *            range radio button
067:             * @param tree
068:             *            service tree
069:             * @param table
070:             *            service table
071:             * @param buttonRefresh
072:             *            refresh button
073:             * @param buttonOpen
074:             *            open button
075:             * @param dialog
076:             *            options dialog
077:             * @param textDir
078:             *            directory value field
079:             * @param textSize
080:             *            set size text field
081:             * @param textMax
082:             *            set files maximum size text field
083:             */
084:            public IExplorerService(String name, JButton buttonClear,
085:                    JDialog dialogClear, JButton buttonStart,
086:                    JButton buttonEnd, JComboBox box, JDialog dialogDate,
087:                    AbstractButton b1, AbstractButton b2, JTree tree,
088:                    JTable table, JButton buttonRefresh, JButton buttonOpen,
089:                    JDialog dialog, JTextField textDir,
090:                    JFormattedTextField textSize, JFormattedTextField textMax) {
091:                super (ExplorerServiceMBean.class, name, buttonClear,
092:                        dialogClear, buttonStart, buttonEnd, box, dialogDate,
093:                        b1, b2);
094:                this .tree = tree;
095:                model = (DefaultTreeModel) tree.getModel();
096:                root = (IExplorerNode) model.getRoot();
097:                this .table = table;
098:                mFile = (IExplorerModel) table.getModel();
099:                tree.addTreeSelectionListener(this );
100:                tree.addTreeExpansionListener(this );
101:                table.getSelectionModel().addListSelectionListener(this );
102:                this .buttonRefresh = buttonRefresh;
103:                buttonRefresh.addActionListener(this );
104:                this .buttonOpen = buttonOpen;
105:                buttonOpen.setEnabled(false);
106:                buttonOpen.addActionListener(this );
107:                this .dialog = dialog;
108:                optionPane = (JOptionPane) dialog.getContentPane();
109:                optionPane.addPropertyChangeListener(this );
110:                this .textDir = textDir;
111:                this .textSize = textSize;
112:                this .textMax = textMax;
113:                updateUI();
114:            }
115:
116:            public void valueChanged(TreeSelectionEvent e) {
117:                IExplorerNode node = (IExplorerNode) tree
118:                        .getLastSelectedPathComponent();
119:                if (node == null)
120:                    node = root;
121:                mFile.setData(listFiles(node.dir, pc));
122:            }
123:
124:            public void valueChanged(ListSelectionEvent e) {
125:                if (e.getValueIsAdjusting())
126:                    return;
127:                if (table.getSelectedRow() == -1)
128:                    buttonOpen.setEnabled(false);
129:                else {
130:                    buttonOpen.setEnabled(true);
131:                    JTextComponent t = new JTextField(((IExplorerDoc) table
132:                            .getValueAt(table.getSelectedRow(), 0)).file);
133:                    t.selectAll();
134:                    t.copy();
135:                }
136:            }
137:
138:            protected void hold() {
139:                super .hold();
140:                buttonRefresh.setEnabled(false);
141:                tree.setEnabled(false);
142:            }
143:
144:            public void actionPerformed(ActionEvent e) {
145:                Object source = e.getSource();
146:                if (source == buttonOpen) {
147:                    try {
148:                        Desktop.browse(new URL(((IExplorerDoc) table
149:                                .getValueAt(table.getSelectedRow(), 0)).file));
150:                    } catch (Exception ex) {
151:                        Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
152:                    }
153:                } else if (source == buttonRefresh) {
154:                    tree.collapseRow(0);
155:                    tree.expandRow(0);
156:                } else {
157:                    dialog.setLocationRelativeTo(dialog.getOwner());
158:                    dialog.setVisible(true);
159:                    Object value = optionPane.getValue();
160:                    if (value == JOptionPane.UNINITIALIZED_VALUE)
161:                        return;
162:                    optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
163:                    if (((Integer) value).intValue() != JOptionPane.OK_OPTION)
164:                        return;
165:                    ExplorerService s = new ExplorerService();
166:                    s.setDir(textDir.getText());
167:                    s.setSize((Long) textSize.getValue());
168:                    s.setMax((Long) textMax.getValue());
169:                    try {
170:                        setAttribute(FileServiceMBean.OPTIONS, s);
171:                    } catch (Exception ex) {
172:                        Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
173:                    }
174:                }
175:            }
176:
177:            protected void set() {
178:                super .set();
179:                buttonRefresh.setEnabled(isDirExists);
180:                tree.setEnabled(isDirExists);
181:                if (!isDirExists) {
182:                    root.removeAllChildren();
183:                    model.reload();
184:                }
185:            }
186:
187:            public void updateUI() {
188:                SwingUtilities.updateComponentTreeUI(dialog);
189:                super .updateUI();
190:            }
191:
192:            public void treeExpanded(TreeExpansionEvent event) {
193:                hold();
194:                final IExplorerNode node = (IExplorerNode) event.getPath()
195:                        .getLastPathComponent();
196:                node.removeAllChildren();
197:                model.reload(node);
198:                new Thread() {
199:                    public void run() {
200:                        final File[] list = select(node.dir, pc);
201:                        SwingUtilities.invokeLater(new Runnable() {
202:                            public void run() {
203:                                if (list != null)
204:                                    for (File f : list) {
205:                                        Thread.yield();
206:                                        node.add(new IExplorerNode(f, null));
207:                                        model.reload(node);
208:                                    }
209:                                IExplorerService.this .set();
210:                            }
211:                        });
212:                    }
213:                }.start();
214:            }
215:
216:            public void treeCollapsed(TreeExpansionEvent event) {
217:            }
218:
219:            public File[] select(File file, PeriodControl pc) {
220:                return ((ExplorerServiceMBean) melement).select(file, pc);
221:            }
222:
223:            public long lastModified(File file) {
224:                return ((ExplorerServiceMBean) melement).lastModified(file);
225:            }
226:
227:            public File[] listFiles(File file, PeriodControl pc) {
228:                return ((ExplorerServiceMBean) melement).listFiles(file, pc);
229:            }
230:
231:            protected void otherNotification(String type, Object value) {
232:                if (type.equals(FileServiceMBean.OPTIONS)) {
233:                    textDir.setText(((FileService) value).getDir());
234:                    textSize.setValue(((ExplorerService) value).getSize());
235:                    textMax.setValue(((ExplorerService) value).getMax());
236:                }
237:                super.otherNotification(type, value);
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.