001/* Dialog to configure execution monitor table. 002 * 003 * Copyright (c) 2015 The Regents of the University of California. 004 * All rights reserved. 005 * 006 * '$Author: crawl $' 007 * '$Date: 2015-11-02 19:58:53 +0000 (Mon, 02 Nov 2015) $' 008 * '$Revision: 34196 $' 009 * 010 * Permission is hereby granted, without written agreement and without 011 * license or royalty fees, to use, copy, modify, and distribute this 012 * software and its documentation for any purpose, provided that the above 013 * copyright notice and the following two paragraphs appear in all copies 014 * of this software. 015 * 016 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 017 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 018 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 019 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 020 * SUCH DAMAGE. 021 * 022 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 023 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 025 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 026 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 027 * ENHANCEMENTS, OR MODIFICATIONS. 028 * 029 */ 030package org.kepler.profiling.gui; 031 032import java.awt.GridBagConstraints; 033import java.awt.GridBagLayout; 034import java.awt.Insets; 035import java.awt.event.ActionEvent; 036import java.awt.event.ActionListener; 037 038import javax.swing.JButton; 039import javax.swing.JCheckBox; 040import javax.swing.JDialog; 041import javax.swing.JLabel; 042import javax.swing.JTextField; 043import javax.swing.SwingConstants; 044 045import ptolemy.util.MessageHandler; 046 047/** A dialog to configure the execution monitor. 048 * 049 * @author Daniel Crawl 050 * @version $Id: ExecutionPanelConfigureDialog.java 34196 2015-11-02 19:58:53Z crawl $ 051 * 052 */ 053public class ExecutionPanelConfigureDialog extends JDialog { 054 055 /** Create a new ConfigureDialog for the specified monitor. */ 056 public ExecutionPanelConfigureDialog(final ExecutionMonitorPanel monitor, 057 boolean isRunning) { 058 super(monitor.getParentFrame(), "Configure", true); 059 060 setLocationRelativeTo(null); 061 setLayout(new GridBagLayout()); 062 063 GridBagConstraints c = new GridBagConstraints(); 064 065 c.anchor = GridBagConstraints.LINE_START; 066 067 c.insets = new Insets(5,3,0,0); 068 c.gridx = 0; 069 c.gridy = 0; 070 add(new JLabel("Update delay (ms)"), c); 071 072 c.insets = new Insets(5,10,0,0); 073 c.gridx = 1; 074 _delayField = new JTextField(5); 075 _delayField.setText(String.valueOf(monitor.getUpdateDelay())); 076 _delayField.addActionListener(new ActionListener() { 077 @Override 078 public void actionPerformed(ActionEvent event) { 079 _setUpdateDelay(monitor); 080 } 081 }); 082 add(_delayField, c); 083 084 c.gridwidth = 2; 085 c.gridx = 0; 086 c.gridy = 1; 087 c.insets = new Insets(0,0,0,0); 088 final JCheckBox separateCheckBox = 089 new JCheckBox("Separate actor executions."); 090 separateCheckBox.setSelected(monitor.getSeparateActorExecutions()); 091 separateCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); 092 separateCheckBox.setBorderPainted(false); 093 separateCheckBox.addActionListener(new ActionListener() { 094 @Override 095 public void actionPerformed(ActionEvent e) { 096 monitor.setSeparateActorExecutions(separateCheckBox.isSelected()); 097 } 098 }); 099 if(isRunning) { 100 separateCheckBox.setEnabled(false); 101 } 102 add(separateCheckBox, c); 103 104 c.gridwidth = 2; 105 c.gridx = 0; 106 c.gridy = 2; 107 c.insets = new Insets(0,0,0,0); 108 final JCheckBox showCompositesCheckBox = 109 new JCheckBox("Show composite actor executions."); 110 showCompositesCheckBox.setSelected(monitor.getShowCompositeActorExecutions()); 111 showCompositesCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); 112 showCompositesCheckBox.setBorderPainted(false); 113 showCompositesCheckBox.addActionListener(new ActionListener() { 114 @Override 115 public void actionPerformed(ActionEvent e) { 116 monitor.setShowCompositeActorExecutions(showCompositesCheckBox.isSelected()); 117 } 118 }); 119 if(isRunning) { 120 showCompositesCheckBox.setEnabled(false); 121 } 122 add(showCompositesCheckBox, c); 123 124 c.anchor = GridBagConstraints.CENTER; 125 c.gridy = 3; 126 JButton okButton = new JButton("OK"); 127 okButton.addActionListener(new ActionListener() { 128 @Override 129 public void actionPerformed(ActionEvent e) { 130 // set the delay since the value in the text field might 131 // have changed, but _delayField's action listener was 132 // not called. 133 _setUpdateDelay(monitor); 134 ExecutionPanelConfigureDialog.this.dispose(); 135 } 136 }); 137 add(okButton, c); 138 } 139 140 /** Set the update delay in the execution monitor. */ 141 private void _setUpdateDelay(ExecutionMonitorPanel monitor) { 142 String text = _delayField.getText(); 143 try { 144 Integer delay = Integer.valueOf(text); 145 monitor.setUpdateDelay(delay); 146 } catch(NumberFormatException e) { 147 MessageHandler.error("Enter a number for the update delay."); 148 } 149 } 150 151 /** The amount of time to delay updating the table. */ 152 private JTextField _delayField; 153}