001/* Singleton class for displaying exceptions, errors, warnings, and messages that 002includes a button to open the actor that caused the problem and that zooms in to the actor. 003 004 Copyright (c) 2012-2014 The Regents of the University of California. 005 All rights reserved. 006 Permission is hereby granted, without written agreement and without 007 license or royalty fees, to use, copy, modify, and distribute this 008 software and its documentation for any purpose, provided that the above 009 copyright notice and the following two paragraphs appear in all copies 010 of this software. 011 012 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 013 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 014 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 015 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 016 SUCH DAMAGE. 017 018 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 019 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 020 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 021 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 022 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 023 ENHANCEMENTS, OR MODIFICATIONS. 024 025 PT_COPYRIGHT_VERSION_2 026 COPYRIGHTENDKEY 027 */ 028package ptolemy.vergil; 029 030import ptolemy.actor.gui.ActorGraphicalMessageHandler; 031import ptolemy.kernel.util.Nameable; 032import ptolemy.kernel.util.NamedObj; 033import ptolemy.vergil.basic.BasicGraphFrame; 034 035/////////////////////////////////////////////////////////////////// 036//// VergilGraphicalMessageHandler 037 038/** 039 A message handler that optionally includes a button that opens the model 040 that contains the actor that caused the exception and zooms into the actor. 041 042 @author Christopher Brooks 043 @version $Id$ 044 @since Ptolemy II 10.0 045 @Pt.ProposedRating Red (cxh) 046 @Pt.AcceptedRating Red (cxh) 047 */ 048public class VergilGraphicalMessageHandler 049 extends ActorGraphicalMessageHandler { 050 051 /** Open the level of hierarchy of the model that contains the 052 * Nameable referred to by the KernelException or KernelRuntimeException and 053 * possibly zoom in. 054 * @param throwable The throwable that may be a KernelException 055 * or KernelRuntimeException. 056 */ 057 @Override 058 protected void _showNameable(Throwable throwable) { 059 Nameable nameable1 = _getNameable(throwable); 060 if (nameable1 != null) { 061 BasicGraphFrame.openComposite(null, (NamedObj) nameable1); 062 return; 063 } 064 065 message("Internal Error: The throwable \"" + throwable 066 + "\" is not a KernelException or KernelRuntimeException?"); 067 } 068}