Source Code Cross Referenced for ImRManagerGUI.java in  » Collaboration » JacORB » org » jacorb » imr » util » 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 » Collaboration » JacORB » org.jacorb.imr.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jacorb.imr.util;
002:
003:        /*
004:         *        JacORB - a free Java ORB
005:         *
006:         *   Copyright (C) 1999-2004 Gerald Brose
007:         *
008:         *   This library is free software; you can redistribute it and/or
009:         *   modify it under the terms of the GNU Library General Public
010:         *   License as published by the Free Software Foundation; either
011:         *   version 2 of the License, or (at your option) any later version.
012:         *
013:         *   This library is distributed in the hope that it will be useful,
014:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         *   Library General Public License for more details.
017:         *
018:         *   You should have received a copy of the GNU Library General Public
019:         *   License along with this library; if not, write to the Free
020:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        import javax.swing.*;
025:        import java.awt.*;
026:        import java.awt.event.*;
027:        import javax.swing.tree.*;
028:        import javax.swing.border.*;
029:        import javax.swing.event.*;
030:        import javax.swing.table.*;
031:        import javax.swing.event.ListSelectionListener;
032:        import javax.swing.event.ListSelectionEvent;
033:        import java.awt.event.MouseEvent;
034:        import java.awt.event.MouseListener;
035:        import java.io.Serializable;
036:
037:        import org.jacorb.imr.*;
038:
039:        /**
040:         * The GUI'ed version of the ImRManager.
041:         *
042:         * @author Nicolas Noffke
043:         * @version $Id: ImRManagerGUI.java,v 1.9 2006/06/27 10:38:29 alphonse.bendt Exp $
044:         *
045:         */
046:
047:        public class ImRManagerGUI extends JFrame {
048:            private JMenuItem m_exit_mi;
049:            private JMenuItem m_about_mi;
050:            private JMenuItem m_refresh_all_mi;
051:            private JMenuItem m_connect_mi;
052:            private JMenuItem m_shutdown_mi;
053:            private JMenuItem m_forcedown_mi;
054:            private JMenuItem m_save_mi;
055:            private JMenuItem m_add_mi;
056:            private JMenuItem m_remove_mi;
057:            private JMenuItem m_hold_mi;
058:            private JMenuItem m_release_mi;
059:            private JMenuItem m_setdown_mi;
060:            private JMenuItem m_refresh_mi;
061:            private JMenuItem m_auto_refresh_mi;
062:
063:            private EventHandler m_handler;
064:            private ImRModel m_model;
065:
066:            private DefaultMutableTreeNode m_top_node;
067:            private JTree m_tree;
068:
069:            private JPanel m_table_panel;
070:            private JScrollPane m_server_view;
071:            private JScrollPane m_poa_view;
072:            private JScrollPane m_tree_view;
073:
074:            private JTable m_server_table;
075:            private JTable m_poa_table;
076:
077:            private JPopupMenu m_context_menu;
078:            private JMenuItem m_add_cmi;
079:            private JMenuItem m_remove_cmi;
080:            private JMenuItem m_hold_cmi;
081:            private JMenuItem m_release_cmi;
082:            private JMenuItem m_setdown_cmi;
083:            private JMenuItem m_refresh_cmi;
084:
085:            /**
086:             * The constructor. Instanciates all components and brings up the window.
087:             */
088:            public ImRManagerGUI() {
089:                super ("ImR Manager");
090:                m_handler = new EventHandler();
091:                m_model = new ImRModel();
092:
093:                try {
094:                    UIManager.setLookAndFeel(UIManager
095:                            .getCrossPlatformLookAndFeelClassName());
096:                } catch (Exception e) {
097:                }
098:
099:                GridBagConstraints _constraints = new GridBagConstraints();
100:
101:                //Build menu bar
102:                JMenuBar _menu_bar = new JMenuBar();
103:                setJMenuBar(_menu_bar);
104:
105:                JMenu _manager_menu = new JMenu("Manager");
106:                _menu_bar.add(_manager_menu);
107:
108:                JMenu _imr_menu = new JMenu("ImR");
109:                _menu_bar.add(_imr_menu);
110:
111:                JMenu _server_menu = new JMenu("Server");
112:                _menu_bar.add(_server_menu);
113:
114:                //build manager menu entries
115:                m_about_mi = new JMenuItem("About...");
116:                m_about_mi.addActionListener(m_handler);
117:                _manager_menu.add(m_about_mi);
118:
119:                m_auto_refresh_mi = new JMenuItem("Automatic Refresh...");
120:                m_auto_refresh_mi.addActionListener(m_handler);
121:                _manager_menu.add(m_auto_refresh_mi);
122:
123:                m_exit_mi = new JMenuItem("Exit");
124:                m_exit_mi.addActionListener(m_handler);
125:                _manager_menu.add(m_exit_mi);
126:
127:                //build ImR menu entries
128:                m_shutdown_mi = new JMenuItem("Shutdown");
129:                m_shutdown_mi.addActionListener(m_handler);
130:                _imr_menu.add(m_shutdown_mi);
131:
132:                m_forcedown_mi = new JMenuItem("Force Down");
133:                m_forcedown_mi.addActionListener(m_handler);
134:                _imr_menu.add(m_forcedown_mi);
135:
136:                m_save_mi = new JMenuItem("Save Server Table");
137:                m_save_mi.addActionListener(m_handler);
138:                _imr_menu.add(m_save_mi);
139:
140:                _imr_menu.addSeparator();
141:
142:                m_connect_mi = new JMenuItem("Connect...");
143:                m_connect_mi.addActionListener(m_handler);
144:                _imr_menu.add(m_connect_mi);
145:
146:                m_refresh_all_mi = new JMenuItem("Refresh all");
147:                m_refresh_all_mi.addActionListener(m_handler);
148:                _imr_menu.add(m_refresh_all_mi);
149:
150:                //build server menu entries
151:                m_add_mi = new JMenuItem("Add...");
152:                m_add_mi.addActionListener(m_handler);
153:                _server_menu.add(m_add_mi);
154:
155:                m_remove_mi = new JMenuItem("Remove");
156:                m_remove_mi.addActionListener(m_handler);
157:                _server_menu.add(m_remove_mi);
158:
159:                m_hold_mi = new JMenuItem("Hold");
160:                m_hold_mi.addActionListener(m_handler);
161:                _server_menu.add(m_hold_mi);
162:
163:                m_release_mi = new JMenuItem("Release");
164:                m_release_mi.addActionListener(m_handler);
165:                _server_menu.add(m_release_mi);
166:
167:                m_setdown_mi = new JMenuItem("Set Down");
168:                m_setdown_mi.addActionListener(m_handler);
169:                _server_menu.add(m_setdown_mi);
170:
171:                _server_menu.addSeparator();
172:
173:                m_refresh_mi = new JMenuItem("Refresh");
174:                m_refresh_mi.addActionListener(m_handler);
175:                _server_menu.add(m_refresh_mi);
176:
177:                //build popup menu
178:                m_context_menu = new JPopupMenu("Server manipulation");
179:                m_context_menu.setVisible(true);
180:
181:                m_add_cmi = new JMenuItem("Add...");
182:                m_add_cmi.addActionListener(m_handler);
183:                m_context_menu.add(m_add_cmi);
184:
185:                m_remove_cmi = new JMenuItem("Remove");
186:                m_remove_cmi.addActionListener(m_handler);
187:                m_context_menu.add(m_remove_cmi);
188:
189:                m_context_menu.addSeparator();
190:
191:                m_hold_cmi = new JMenuItem("Hold");
192:                m_hold_cmi.addActionListener(m_handler);
193:                m_context_menu.add(m_hold_cmi);
194:
195:                m_release_cmi = new JMenuItem("Release");
196:                m_release_cmi.addActionListener(m_handler);
197:                m_context_menu.add(m_release_cmi);
198:
199:                m_setdown_cmi = new JMenuItem("Set Down");
200:                m_setdown_cmi.addActionListener(m_handler);
201:                m_context_menu.add(m_setdown_cmi);
202:
203:                m_context_menu.addSeparator();
204:
205:                m_refresh_cmi = new JMenuItem("Refresh");
206:                m_refresh_cmi.addActionListener(m_handler);
207:                m_context_menu.add(m_refresh_cmi);
208:
209:                JPanel _top_panel = new JPanel();
210:                GridBagLayout _top_gbl = new GridBagLayout();
211:                _top_panel.setLayout(_top_gbl);
212:
213:                m_tree = m_model.getTree();
214:                m_tree.setEditable(false);
215:                m_tree.setCellRenderer(new ImRTreeCellRenderer());
216:                m_tree.addTreeSelectionListener(m_handler);
217:                m_tree.addMouseListener(m_handler);
218:
219:                ToolTipManager.sharedInstance().registerComponent(m_tree);
220:                m_tree_view = new JScrollPane(m_tree);
221:                m_tree_view.addMouseListener(m_handler);
222:
223:                m_table_panel = new JPanel();
224:
225:                GridBagLayout _table_gbl = new GridBagLayout();
226:                m_table_panel.setLayout(_table_gbl);
227:
228:                TableModel _server_model = m_model.getServerTableModel();
229:                m_server_table = new JTable(_server_model);
230:                m_server_table.addMouseListener(m_handler);
231:
232:                ListSelectionModel _selection_model = m_server_table
233:                        .getSelectionModel();
234:                _selection_model.addListSelectionListener(m_handler);
235:
236:                TableColumn _host_col = m_server_table.getColumnModel()
237:                        .getColumn(1);
238:                _host_col.setCellEditor(new ImRTableCellEditor(m_model
239:                        .getHostSelector()));
240:
241:                m_server_view = new JScrollPane(m_server_table);
242:                m_server_view.setVisible(true);
243:                buildConstraints(_constraints, 0, 0, 1, 1, 1, 1);
244:                _constraints.fill = GridBagConstraints.BOTH;
245:                _table_gbl.setConstraints(m_server_view, _constraints);
246:                m_table_panel.add(m_server_view);
247:
248:                TableModel _poa_model = m_model.getPOATableModel();
249:                m_poa_table = new JTable(_poa_model);
250:                m_poa_view = new JScrollPane(m_poa_table);
251:                m_poa_view.setVisible(false);
252:                buildConstraints(_constraints, 0, 0, 1, 1, 1, 1);
253:                _constraints.fill = GridBagConstraints.BOTH;
254:                _table_gbl.setConstraints(m_poa_view, _constraints);
255:                m_table_panel.add(m_poa_view);
256:
257:                JSplitPane _split_pane = new JSplitPane(
258:                        JSplitPane.HORIZONTAL_SPLIT, m_tree_view, m_table_panel);
259:                _split_pane.setOneTouchExpandable(true);
260:                _split_pane.setDividerLocation(150);
261:
262:                buildConstraints(_constraints, 0, 0, 1, 1, 1, 1);
263:                _constraints.fill = GridBagConstraints.BOTH;
264:                _top_gbl.setConstraints(_split_pane, _constraints);
265:                _top_panel.add(_split_pane);
266:
267:                getContentPane().add(_top_panel);
268:                pack();
269:                setVisible(true);
270:            }
271:
272:            /**
273:             * Shows the POA Table in right part of SplitPane.
274:             */
275:            private void showPOATable() {
276:                if (!m_poa_view.isVisible()) {
277:                    m_server_view.setVisible(false);
278:                    m_poa_view.setVisible(true);
279:                    pack();
280:                    m_table_panel.repaint();
281:                }
282:            }
283:
284:            /**
285:             * Shows the Server Table in right part of SplitPane.
286:             */
287:            private void showServerTable() {
288:                if (!m_server_view.isVisible()) {
289:                    m_poa_view.setVisible(false);
290:                    m_server_view.setVisible(true);
291:                    pack();
292:                    m_table_panel.repaint();
293:                }
294:            }
295:
296:            /**
297:             * Convenience method for setting up the GridBagConstraints.
298:             *
299:             * @param gbc a GridBagConstraint object.
300:             * @param gx x value.
301:             * @param gy y value.
302:             * @param gw width.
303:             * @param gh height.
304:             * @param wx weight x.
305:             * @param wy weight y.
306:             */
307:            private void buildConstraints(GridBagConstraints gbc, int gx,
308:                    int gy, int gw, int gh, int wx, int wy) {
309:                gbc.gridx = gx;
310:                gbc.gridy = gy;
311:                gbc.gridwidth = gw;
312:                gbc.gridheight = gh;
313:                gbc.weightx = wx;
314:                gbc.weighty = wy;
315:            }
316:
317:            /**
318:             * Main method. Brings the GUI up.
319:             */
320:            public static void main(String[] args) {
321:                new ImRManagerGUI();
322:            }
323:
324:            /**
325:             * This class handles all occuring events.
326:             */
327:            private class EventHandler implements  MouseListener,
328:                    ListSelectionListener, TreeSelectionListener,
329:                    ActionListener, Serializable {
330:
331:                // implementation of java.awt.event.ActionListener interface
332:                /**
333:                 * This method responds to menu selections.
334:                 *
335:                 * @param event
336:                 */
337:                public void actionPerformed(ActionEvent event) {
338:                    Object _source = event.getSource();
339:
340:                    if (_source instanceof  JMenuItem) {
341:                        if ((JMenuItem) _source == m_exit_mi)
342:                            System.exit(0);
343:
344:                        else if ((JMenuItem) _source == m_about_mi)
345:                            JOptionPane
346:                                    .showMessageDialog(
347:                                            new JFrame(),
348:                                            "FUB - Institute for Computer Sciences\n\n"
349:                                                    + "The man with the plan: Gerald Brose\n"
350:                                                    + "The imp to get along with the plans: Nicolas Noffke\n");
351:
352:                        else if ((JMenuItem) _source == m_auto_refresh_mi)
353:                            new RefreshWindow(m_model);
354:
355:                        else if ((JMenuItem) _source == m_refresh_all_mi) {
356:                            m_model.fetchServers();
357:                            showServerTable();
358:                        }
359:
360:                        else if ((JMenuItem) _source == m_connect_mi)
361:                            new ConnectWindow(m_model);
362:
363:                        else if ((JMenuItem) _source == m_shutdown_mi)
364:                            m_model.imrShutdown(true);
365:
366:                        else if ((JMenuItem) _source == m_forcedown_mi)
367:                            m_model.imrShutdown(false);
368:
369:                        else if ((JMenuItem) _source == m_save_mi)
370:                            m_model.saveTable();
371:
372:                        else if ((JMenuItem) _source == m_add_mi
373:                                || (JMenuItem) _source == m_add_cmi)
374:                            new AddServerWindow(m_model);
375:
376:                        else if ((JMenuItem) _source == m_remove_mi
377:                                || (JMenuItem) _source == m_remove_cmi) {
378:                            int _select = m_server_table.getSelectedRow();
379:                            if (_select > -1)
380:                                m_model.removeServer(_select);
381:                            else {
382:                                TreePath _selected_path = m_tree
383:                                        .getSelectionPath();
384:                                if (_selected_path != null) {
385:                                    DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
386:                                            .getLastPathComponent();
387:                                    Object _imr_node = _node.getUserObject();
388:
389:                                    if (_imr_node instanceof  ServerInfo)
390:                                        m_model
391:                                                .removeServer(((ServerInfo) _imr_node).name);
392:                                    else
393:                                        System.out
394:                                                .println("Please select a server node!");
395:                                } else
396:                                    System.out
397:                                            .println("Please select a server to remove!");
398:                            }
399:                        } else if ((JMenuItem) _source == m_hold_mi
400:                                || (JMenuItem) _source == m_hold_cmi) {
401:                            int _select = m_server_table.getSelectedRow();
402:                            if (_select > -1)
403:                                m_model.holdServer(_select);
404:                            else {
405:                                TreePath _selected_path = m_tree
406:                                        .getSelectionPath();
407:                                if (_selected_path != null) {
408:                                    DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
409:                                            .getLastPathComponent();
410:                                    Object _imr_node = _node.getUserObject();
411:
412:                                    if (_imr_node instanceof  ServerInfo)
413:                                        m_model
414:                                                .holdServer(((ServerInfo) _imr_node).name);
415:                                    else
416:                                        System.out
417:                                                .println("Please select a server node!");
418:                                } else
419:                                    System.out
420:                                            .println("Please select a server to hold!");
421:                            }
422:                        } else if ((JMenuItem) _source == m_refresh_mi
423:                                || (JMenuItem) _source == m_refresh_cmi) {
424:                            int _select = m_server_table.getSelectedRow();
425:                            if (_select > -1)
426:                                m_model.refreshServer(_select);
427:                            else {
428:                                TreePath _selected_path = m_tree
429:                                        .getSelectionPath();
430:                                if (_selected_path != null) {
431:                                    DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
432:                                            .getLastPathComponent();
433:                                    Object _imr_node = _node.getUserObject();
434:
435:                                    if (_imr_node instanceof  ServerInfo)
436:                                        m_model
437:                                                .refreshServer(((ServerInfo) _imr_node).name);
438:                                    else
439:                                        System.out
440:                                                .println("Please select a server node!");
441:                                } else
442:                                    System.out
443:                                            .println("Please select a server to refresh!");
444:                            }
445:                        } else if ((JMenuItem) _source == m_release_mi
446:                                || (JMenuItem) _source == m_release_cmi) {
447:                            int _select = m_server_table.getSelectedRow();
448:                            if (_select > -1)
449:                                m_model.releaseServer(_select);
450:                            else {
451:                                TreePath _selected_path = m_tree
452:                                        .getSelectionPath();
453:                                if (_selected_path != null) {
454:                                    DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
455:                                            .getLastPathComponent();
456:                                    Object _imr_node = _node.getUserObject();
457:
458:                                    if (_imr_node instanceof  ServerInfo)
459:                                        m_model
460:                                                .releaseServer(((ServerInfo) _imr_node).name);
461:                                    else
462:                                        System.out
463:                                                .println("Please select a server node!");
464:                                } else
465:                                    System.out
466:                                            .println("Please select a server to release!");
467:                            }
468:                        } else if ((JMenuItem) _source == m_setdown_mi
469:                                || (JMenuItem) _source == m_setdown_cmi) {
470:                            int _select = m_server_table.getSelectedRow();
471:                            if (_select > -1)
472:                                m_model.setServerDown(_select);
473:                            else {
474:                                TreePath _selected_path = m_tree
475:                                        .getSelectionPath();
476:                                if (_selected_path != null) {
477:                                    DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
478:                                            .getLastPathComponent();
479:                                    Object _imr_node = _node.getUserObject();
480:
481:                                    if (_imr_node instanceof  ServerInfo)
482:                                        m_model
483:                                                .setServerDown(((ServerInfo) _imr_node).name);
484:                                    else
485:                                        System.out
486:                                                .println("Please select a server node!");
487:                                } else
488:                                    System.out
489:                                            .println("Please select a server to set down!");
490:                            }
491:                        }
492:                    }
493:                }
494:
495:                // implementation of javax.swing.event.TreeSelectionListener interface
496:                /**
497:                 * Respond to node selections in tree. Shows brings up desired table,
498:                 * and deletes the previous selection in the tables.
499:                 *
500:                 * @param event
501:                 */
502:                public void valueChanged(TreeSelectionEvent event) {
503:                    DefaultMutableTreeNode _select = (DefaultMutableTreeNode) (event
504:                            .getPath().getLastPathComponent());
505:                    Object _node_obj = _select.getUserObject();
506:
507:                    if (_node_obj instanceof  ServerInfo) {
508:                        m_poa_table.clearSelection();
509:                        m_server_table.clearSelection();
510:                        showServerTable();
511:                    } else if (_node_obj instanceof  ImRInfo) {
512:                        m_server_table.clearSelection();
513:                        showServerTable();
514:                    } else if (_node_obj instanceof  POAInfo) {
515:                        m_server_table.clearSelection();
516:                        ServerInfo _parent = (ServerInfo) ((DefaultMutableTreeNode) _select
517:                                .getParent()).getUserObject();
518:                        m_model.poaTableForServer(_parent);
519:
520:                        if (m_poa_table.getRowCount() > 1) {
521:                            int _row = m_model.getRow(_parent,
522:                                    (POAInfo) _node_obj);
523:                            m_poa_table.clearSelection();
524:                            m_poa_table.setRowSelectionInterval(_row, _row);
525:                        }
526:
527:                        showPOATable();
528:                    }
529:                }
530:
531:                // implementation of javax.swing.event.ListSelectionListener interface
532:                /**
533:                 * Delete selection in tree, if a table row has been selected.
534:                 *
535:                 * @param event
536:                 */
537:                public void valueChanged(ListSelectionEvent event) {
538:                    if (!((ListSelectionModel) event.getSource())
539:                            .isSelectionEmpty())
540:                        m_tree.clearSelection();
541:                }
542:
543:                // implementation of java.awt.event.MouseListener interface
544:                /**
545:                 * Bring up popup menu.
546:                 *
547:                 * @param event
548:                 */
549:                public void mouseClicked(MouseEvent event) {
550:                    maybeShowContextMenu(event);
551:                }
552:
553:                /**
554:                 * NOT IMPLEMENTED
555:                 */
556:                public void mouseEntered(MouseEvent param1) {
557:                    // NOT IMPLEMENTED
558:                }
559:
560:                /**
561:                 * NOT IMPLEMENTED
562:                 */
563:                public void mouseExited(MouseEvent param1) {
564:                    // NOT IMPLEMENTED
565:                }
566:
567:                /**
568:                 * Bring up popup menu.
569:                 */
570:                public void mousePressed(MouseEvent event) {
571:                    maybeShowContextMenu(event);
572:                }
573:
574:                /**
575:                 * Bring up popup menu.
576:                 */
577:                public void mouseReleased(MouseEvent event) {
578:                    maybeShowContextMenu(event);
579:                }
580:
581:                /**
582:                 * Test whether to bring up popup menu, or not.
583:                 * This is the case, when a server is selected
584:                 * (in the tree or in the table).
585:                 */
586:                private void maybeShowContextMenu(MouseEvent event) {
587:                    if (event.isPopupTrigger()) {
588:                        Component _source = event.getComponent();
589:                        if (_source == m_server_table) {
590:                            if (m_server_table.getSelectedRow() > -1)
591:                                m_context_menu.show(_source, event.getX(),
592:                                        event.getY());
593:                        } else if (_source == m_tree) {
594:                            TreePath _selected_path = m_tree.getSelectionPath();
595:                            if (_selected_path != null) {
596:                                DefaultMutableTreeNode _node = (DefaultMutableTreeNode) _selected_path
597:                                        .getLastPathComponent();
598:
599:                                if (_node.getUserObject() instanceof  ServerInfo)
600:                                    m_context_menu.show(_source, event.getX(),
601:                                            event.getY());
602:                            }
603:                        }
604:                    }
605:                }
606:            }//EventHandler
607:
608:        } // ImRManagerGUI
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.