001/* 002 * Copyright (c) 2009-2015 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2015-11-02 19:57:48 +0000 (Mon, 02 Nov 2015) $' 007 * '$Revision: 34194 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029package org.kepler.profiling.gui; 030 031import java.awt.BorderLayout; 032import java.awt.event.ActionEvent; 033import java.awt.event.ActionListener; 034 035import javax.swing.JButton; 036import javax.swing.JCheckBox; 037import javax.swing.JPanel; 038import javax.swing.JScrollPane; 039import javax.swing.JTree; 040import javax.swing.ScrollPaneConstants; 041 042import org.kepler.gui.TabPane; 043import org.kepler.gui.TabPaneFactory; 044 045import ptolemy.actor.gui.TableauFrame; 046import ptolemy.kernel.CompositeEntity; 047import ptolemy.kernel.util.IllegalActionException; 048import ptolemy.kernel.util.NameDuplicationException; 049import ptolemy.kernel.util.NamedObj; 050 051/** A tab pane display an workflow outline of actor execution time. 052 * 053 * @author Daniel Crawl 054 * @version $Id: ActorFireOutlineTabPane.java 34194 2015-11-02 19:57:48Z crawl $ 055 */ 056public class ActorFireOutlineTabPane extends WorkflowRunOutlineTabPane { 057 058 @Override 059 protected void _finishRefreshOutline(NamedObj root) { 060 061 boolean includeFires = false; 062 if(_wfOutlineTreeModel != null) 063 { 064 includeFires = _wfOutlineTreeModel.includeFires; 065 } 066 _wfOutlineTreeModel = new WorkflowOutlineTreeActorFireModel((CompositeEntity) root); 067 _wfOutlineTreeModel.includeFires = includeFires; 068 069 final AnnotatedActorFirePTree treePane = new AnnotatedActorFirePTree(_wfOutlineTreeModel, this, true, root); 070 071 JScrollPane jSP = new JScrollPane(treePane, 072 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 073 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); 074 //jSP.setPreferredSize(new Dimension(200, 200)); 075 076 add(jSP, BorderLayout.CENTER); 077 078 _toggleCheckbox = new JCheckBox("Show Fires"); 079 _toggleCheckbox.setSelected(includeFires); 080 _toggleCheckbox.addActionListener(new ActionListener() { 081 @Override 082 public void actionPerformed(ActionEvent e) { 083 if (e.getSource() == _toggleCheckbox) { 084 _wfOutlineTreeModel.includeFires = _toggleCheckbox.isSelected(); 085 _refreshOutline(); 086 } 087 } 088 }); 089 090 JButton expandAll = new JButton("Expand All"); 091 expandAll.addActionListener(new ActionListener() { 092 @Override 093 public void actionPerformed(ActionEvent e) { 094 _expandAll(treePane, 0, treePane.getRowCount()); 095 } 096 097 private void _expandAll(JTree tree, int startingIndex, int rowCount) { 098 for(int i = startingIndex; i < rowCount; i++) { 099 tree.expandRow(i); 100 } 101 102 if(tree.getRowCount() != rowCount) { 103 _expandAll(tree, rowCount, tree.getRowCount()); 104 } 105 } 106 }); 107 108 109 JPanel southPanel = new JPanel(new BorderLayout()); 110 southPanel.add(_toggleCheckbox, BorderLayout.WEST); 111 southPanel.add(expandAll, BorderLayout.EAST); 112 113 add(southPanel, BorderLayout.SOUTH); 114 115 repaint(); 116 validate(); 117 } 118 119 public static class Factory extends TabPaneFactory { 120 121 public Factory(NamedObj container, String name) 122 throws IllegalActionException, NameDuplicationException { 123 super(container, name); 124 } 125 126 @Override 127 public TabPane createTabPane(TableauFrame parent) { 128 ActorFireOutlineTabPane pane = new ActorFireOutlineTabPane(); 129 pane.setTabName(this.getName()); 130 return pane; 131 } 132 } 133 134 private WorkflowOutlineTreeActorFireModel _wfOutlineTreeModel; 135}