Showing the changes to java/pkg/com/sun/tools/example/debug/gui/Environment.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,156 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 1999, 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 | package com.sun.tools.example.debug.gui; | ||
| 27 | |||
| 28 | import java.io.*; | ||
| 29 | import com.sun.jdi.*; | ||
| 30 | import com.sun.tools.example.debug.bdi.*; | ||
| 31 | |||
| 32 | public class Environment { | ||
| 33 | |||
| 34 | private SourceManager sourceManager; | ||
| 35 | private ClassManager classManager; | ||
| 36 | private ContextManager contextManager; | ||
| 37 | private MonitorListModel monitorListModel; | ||
| 38 | private ExecutionManager runtime; | ||
| 39 | |||
| 40 | private PrintWriter typeScript; | ||
| 41 | |||
| 42 | private boolean verbose; | ||
| 43 | |||
| 44 | public Environment() { | ||
| 45 | this.classManager = new ClassManager(this); | ||
| 46 | //### Order of the next three lines is important! (FIX THIS) | ||
| 47 | this.runtime = new ExecutionManager(); | ||
| 48 | this.sourceManager = new SourceManager(this); | ||
| 49 | this.contextManager = new ContextManager(this); | ||
| 50 | this.monitorListModel = new MonitorListModel(this); | ||
| 51 | } | ||
| 52 | |||
| 53 | // Services used by debugging tools. | ||
| 54 | |||
| 55 | public SourceManager getSourceManager() { | ||
| 56 | return sourceManager; | ||
| 57 | } | ||
| 58 | |||
| 59 | public ClassManager getClassManager() { | ||
| 60 | return classManager; | ||
| 61 | } | ||
| 62 | |||
| 63 | public ContextManager getContextManager() { | ||
| 64 | return contextManager; | ||
| 65 | } | ||
| 66 | |||
| 67 | public MonitorListModel getMonitorListModel() { | ||
| 68 | return monitorListModel; | ||
| 69 | } | ||
| 70 | |||
| 71 | public ExecutionManager getExecutionManager() { | ||
| 72 | return runtime; | ||
| 73 | } | ||
| 74 | |||
| 75 | //### TODO: | ||
| 76 | //### Tools should attach/detach from environment | ||
| 77 | //### via a property, which should call an 'addTool' | ||
| 78 | //### method when set to maintain a registry of | ||
| 79 | //### tools for exit-time cleanup, etc. Tool | ||
| 80 | //### class constructors should be argument-free, so | ||
| 81 | //### that they may be instantiated by bean builders. | ||
| 82 | //### Will also need 'removeTool' in case property | ||
| 83 | //### value is changed. | ||
| 84 | // | ||
| 85 | // public void addTool(Tool t); | ||
| 86 | // public void removeTool(Tool t); | ||
| 87 | |||
| 88 | public void terminate() { | ||
| 89 | System.exit(0); | ||
| 90 | } | ||
| 91 | |||
| 92 | // public void refresh(); // notify all tools to refresh their views | ||
| 93 | |||
| 94 | |||
| 95 | // public void addStatusListener(StatusListener l); | ||
| 96 | // public void removeStatusListener(StatusListener l); | ||
| 97 | |||
| 98 | // public void addOutputListener(OutputListener l); | ||
| 99 | // public void removeOutputListener(OutputListener l); | ||
| 100 | |||
| 101 | public void setTypeScript(PrintWriter writer) { | ||
| 102 | typeScript = writer; | ||
| 103 | } | ||
| 104 | |||
| 105 | public void error(String message) { | ||
| 106 | if (typeScript != null) { | ||
| 107 | typeScript.println(message); | ||
| 108 | } else { | ||
| 109 | System.out.println(message); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | public void failure(String message) { | ||
| 114 | if (typeScript != null) { | ||
| 115 | typeScript.println(message); | ||
| 116 | } else { | ||
| 117 | System.out.println(message); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | public void notice(String message) { | ||
| 122 | if (typeScript != null) { | ||
| 123 | typeScript.println(message); | ||
| 124 | } else { | ||
| 125 | System.out.println(message); | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | public OutputSink getOutputSink() { | ||
| 130 | return new OutputSink(typeScript); | ||
| 131 | } | ||
| 132 | |||
| 133 | public void viewSource(String fileName) { | ||
| 134 | //### HACK ### | ||
| 135 | //### Should use listener here. | ||
| 136 | com.sun.tools.example.debug.gui.GUI.srcTool.showSourceFile(fileName); | ||
| 137 | } | ||
| 138 | |||
| 139 | public void viewLocation(Location locn) { | ||
| 140 | //### HACK ### | ||
| 141 | //### Should use listener here. | ||
| 142 | //### Should we use sourceForLocation here? | ||
| 143 | com.sun.tools.example.debug.gui.GUI.srcTool.showSourceForLocation(locn); | ||
| 144 | } | ||
| 145 | |||
| 146 | //### Also in 'ContextManager'. Do we need both? | ||
| 147 | |||
| 148 | public boolean getVerboseFlag() { | ||
| 149 | return verbose; | ||
| 150 | } | ||
| 151 | |||
| 152 | public void setVerboseFlag(boolean verbose) { | ||
| 153 | this.verbose = verbose; | ||
| 154 | } | ||
| 155 | |||
| 156 | } | ||