01: /*
02: * BreakpointPanel.java
03: *
04: * Copyright (C) 2002-2003 Peter Graves
05: * $Id: BreakpointPanel.java,v 1.3 2003/05/23 17:43:26 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package org.armedbear.j.jdb;
23:
24: import java.awt.Component;
25: import java.awt.event.KeyEvent;
26: import java.awt.event.KeyListener;
27: import java.util.Vector;
28: import javax.swing.JList;
29: import javax.swing.JScrollPane;
30: import org.armedbear.j.Buffer;
31: import org.armedbear.j.Editor;
32: import org.armedbear.j.File;
33:
34: public final class BreakpointPanel implements BreakpointListener,
35: KeyListener {
36: private final Jdb jdb;
37: private final JdbControlDialog dialog;
38: private final JList list;
39: private final JScrollPane scrollPane;
40:
41: public BreakpointPanel(Jdb jdb, JdbControlDialog dialog) {
42: this .jdb = jdb;
43: this .dialog = dialog;
44: Vector v = new Vector(jdb.getBreakpoints());
45: list = new JList(v);
46: scrollPane = new JScrollPane(list);
47: jdb.addBreakpointListener(this );
48: list.addKeyListener(this );
49: }
50:
51: public Component getComponent() {
52: return scrollPane;
53: }
54:
55: public void breakpointChanged() {
56: list.setListData(new Vector(jdb.getBreakpoints()));
57: list.setSelectedIndex(-1);
58: }
59:
60: public void keyPressed(KeyEvent e) {
61: final int keyCode = e.getKeyCode();
62: // Mask off the bits we don't care about (Java 1.4).
63: final int modifiers = e.getModifiers() & 0x0f;
64: if (modifiers != 0)
65: return;
66: if (keyCode == KeyEvent.VK_DELETE) {
67: int index = list.getSelectedIndex();
68: if (index >= 0) {
69: Object obj = jdb.getBreakpoints().get(index);
70: if (obj instanceof ResolvableBreakpoint) {
71: ResolvableBreakpoint bp = (ResolvableBreakpoint) obj;
72: jdb.log("clear " + bp.getLocationString());
73: jdb.deleteBreakpoint(bp);
74: File file = bp.getFile();
75: if (file != null) {
76: Buffer buffer = Editor.getBufferList()
77: .findBuffer(file);
78: if (buffer != null)
79: buffer.repaint();
80: }
81: jdb.saveSession();
82: jdb.fireBreakpointChanged();
83: if (index >= list.getModel().getSize())
84: --index;
85: list.setSelectedIndex(index);
86: }
87: }
88: }
89: }
90:
91: public void keyTyped(KeyEvent e) {
92: }
93:
94: public void keyReleased(KeyEvent e) {
95: }
96: }
|