001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1997-2004 Gerald Brose.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: */
020:
021: package org.jacorb.naming.namemanager;
022:
023: import java.awt.event.*;
024: import java.awt.*;
025: import javax.swing.tree.*;
026: import javax.swing.*;
027: import org.jacorb.naming.Name;
028: import org.omg.CosNaming.*;
029:
030: /**
031: * This class handles the events on the table
032: */
033:
034: public class TableHandler implements MouseListener, ActionListener,
035: KeyListener {
036: Component frame;
037: JTextField editName;
038: JPopupMenu popup;
039: NSTable table;
040:
041: public TableHandler(Component fr, NSTable t) {
042: frame = fr;
043: table = t;
044: popup = new JPopupMenu();
045: JMenuItem unbind = new JMenuItem("Unbind name");
046: JMenuItem call = new JMenuItem("Call Object...");
047:
048: // until DII client is incorporated...
049: call.setEnabled(false);
050:
051: popup.add(unbind);
052: popup.add(call);
053:
054: unbind.addActionListener(this );
055: call.addActionListener(this );
056: }
057:
058: /**
059: *
060: * @param e java.awt.event.ActionEvent
061: */
062: public void actionPerformed(ActionEvent e) {
063: if (e.getActionCommand().equals("Unbind name")) {
064: table.unbind();
065: } else if (e.getActionCommand().equals("Call Object...")) {
066: // to come: DII pop-up
067: ;
068: } else
069: throw new RuntimeException("sollte nicht auftreten");
070: }
071:
072: /**
073: * @param k java.awt.event.KeyEvent
074: */
075:
076: public void keyPressed(KeyEvent k) {
077: }
078:
079: /**
080: * @param k java.awt.event.KeyEvent
081: */
082:
083: public void keyReleased(KeyEvent k) {
084: if (k.getKeyCode() == KeyEvent.VK_DELETE)
085: table.unbind();
086: }
087:
088: public void keyTyped(KeyEvent k) {
089: }
090:
091: public void mouseClicked(MouseEvent e) {
092: }
093:
094: public void mouseEntered(MouseEvent e) {
095: }
096:
097: public void mouseExited(MouseEvent e) {
098: }
099:
100: // MouseListener
101: public void mousePressed(MouseEvent e) {
102: }
103:
104: // Open context menu
105:
106: public void mouseReleased(MouseEvent e) {
107: if (e.isPopupTrigger()
108: || e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) {
109: popup.pack();
110: popup.show(table, e.getX(), e.getY());
111: }
112: }
113:
114: // WindowListener
115: public void windowClosing(WindowEvent e) {
116: System.exit(0);
117: }
118: }
|