1 /*
   2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * This source code is provided to illustrate the usage of a given feature
  28  * or technique and has been deliberately simplified. Additional steps
  29  * required for a production-quality application, such as security checks,
  30  * input validation and proper error handling, might not be present in
  31  * this sample code.
  32  */
  33 
  34 
  35 package com.sun.tools.example.debug.gui;
  36 
  37 import javax.swing.*;
  38 import java.awt.event.*;
  39 
  40 import com.sun.tools.example.debug.bdi.*;
  41 
  42 class JDBToolBar extends JToolBar {
  43 
  44     Environment env;
  45 
  46     ExecutionManager runtime;
  47     ClassManager classManager;
  48     SourceManager sourceManager;
  49 
  50     CommandInterpreter interpreter;
  51 
  52     JDBToolBar(Environment env) {
  53 
  54         this.env = env;
  55         this.runtime = env.getExecutionManager();
  56         this.classManager = env.getClassManager();
  57         this.sourceManager = env.getSourceManager();
  58         this.interpreter = new CommandInterpreter(env, true);
  59 
  60         //===== Configure toolbar here =====
  61 
  62         addTool("Run application", "run", "run");
  63         addTool("Connect to application", "connect", "connect");
  64         addSeparator();
  65 
  66         addTool("Step into next line", "step", "step");
  67         addTool("Step over next line", "next", "next");
  68 //      addSeparator();
  69 
  70 //      addTool("Step into next instruction", "stepi", "stepi");
  71 //      addTool("Step over next instruction", "nexti", "nexti");
  72 //      addSeparator();
  73 
  74         addTool("Step out of current method call", "step up", "step up");
  75         addSeparator();
  76 
  77         addTool("Suspend execution", "interrupt", "interrupt");
  78         addTool("Continue execution", "cont", "cont");
  79         addSeparator();
  80 
  81 //      addTool("Display current stack", "where", "where");
  82 //      addSeparator();
  83 
  84         addTool("Move up one stack frame", "up", "up");
  85         addTool("Move down one stack frame", "down", "down");
  86 //      addSeparator();
  87 
  88 //      addTool("Display command list", "help", "help");
  89 //      addSeparator();
  90 
  91 //      addTool("Exit debugger", "exit", "exit");
  92 
  93         //==================================
  94 
  95     }
  96 
  97     private void addTool(String toolTip, String labelText, String command) {
  98         JButton button = new JButton(labelText);
  99         button.setToolTipText(toolTip);
 100         final String cmd = command;
 101         button.addActionListener(new ActionListener() {
 102             @Override
 103             public void actionPerformed(ActionEvent e) {
 104                 interpreter.executeCommand(cmd);
 105             }
 106         });
 107         this.add(button);
 108     }
 109 
 110 }