KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > naming > namemanager > TableHandler


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 package org.jacorb.naming.namemanager;
22
23 import java.awt.event.*;
24 import java.awt.*;
25 import javax.swing.tree.*;
26 import javax.swing.*;
27 import org.jacorb.naming.Name;
28 import org.omg.CosNaming.*;
29
30 /**
31  * This class handles the events on the table
32  */

33
34 public class TableHandler
35     implements MouseListener, ActionListener, KeyListener
36 {
37     Component frame;
38     JTextField editName;
39     JPopupMenu popup;
40     NSTable table;
41  
42     public TableHandler(Component fr, NSTable t)
43     {
44         frame=fr;
45         table = t;
46         popup=new JPopupMenu();
47         JMenuItem unbind=new JMenuItem("Unbind name");
48         JMenuItem call=new JMenuItem("Call Object...");
49
50         // until DII client is incorporated...
51
call.setEnabled(false);
52
53         popup.add(unbind);
54         popup.add(call);
55         
56         unbind.addActionListener(this);
57         call.addActionListener(this);
58     }
59     /**
60      *
61      * @param e java.awt.event.ActionEvent
62      */

63     public void actionPerformed(ActionEvent e)
64     {
65         if (e.getActionCommand().equals("Unbind name"))
66         {
67         table.unbind();
68         }
69         else if (e.getActionCommand().equals("Call Object..."))
70         {
71         // to come: DII pop-up
72
;
73         }
74         else
75         throw new RuntimeException JavaDoc("sollte nicht auftreten");
76     }
77     /**
78      * @param k java.awt.event.KeyEvent
79      */

80     
81     public void keyPressed(KeyEvent k) {}
82     /**
83      * @param k java.awt.event.KeyEvent
84      */

85
86     public void keyReleased(KeyEvent k)
87     {
88         if( k.getKeyCode() == KeyEvent.VK_DELETE )
89         table.unbind();
90     }
91
92     public void keyTyped(KeyEvent k) {}
93     public void mouseClicked(MouseEvent e) {}
94     public void mouseEntered(MouseEvent e) {}
95     public void mouseExited(MouseEvent e) {}
96
97     // MouseListener
98
public void mousePressed(MouseEvent e) {}
99
100     // Open context menu
101

102     public void mouseReleased(MouseEvent e)
103     {
104     if (e.isPopupTrigger() || e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK )
105     {
106         popup.pack();
107         popup.show(table, e.getX(), e.getY());
108     }
109     }
110
111     // WindowListener
112
public void windowClosing(WindowEvent e)
113     {
114     System.exit(0);
115     }
116 }
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Popular Tags