|
What this is
Other links
The source code
// $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/AbstractJMeterGuiComponent.java,v 1.31 2004/03/13 20:51:44 sebb Exp $
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.gui;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* This abstract class takes care of the most basic functions necessary to
* create a viable JMeter GUI component. It extends JPanel and implements
* JMeterGUIComponent. This abstract class is, in turn, extended by several
* other abstract classes that create different classes of GUI components for
* JMeter (Visualizers, Timers, Samplers, Modifiers, Controllers, etc).
*
* @see org.apache.jmeter.gui.JMeterGUIComponent
* @see org.apache.jmeter.config.gui.AbstractConfigGui
* @see org.apache.jmeter.assertions.gui.AbstractAssertionGui
* @see org.apache.jmeter.control.gui.AbstractControllerGui
* @see org.apache.jmeter.timers.gui.AbstractTimerGui
* @see org.apache.jmeter.visualizers.gui.AbstractVisualizer
* @see org.apache.jmeter.samplers.gui.AbstractSamplerGui
*
* @version $Revision: 1.31 $ on $Date: 2004/03/13 20:51:44 $
*/
public abstract class AbstractJMeterGuiComponent
extends JPanel
implements JMeterGUIComponent
{
/** Logging */
private static Logger log = LoggingManager.getLoggerForClass();
/** Flag indicating whether or not this component is enabled. */
private boolean enabled = true;
/** The tree node which this component is associated with. */
private JMeterTreeNode node;
/** A GUI panel containing the name of this component. */
private NamePanel namePanel;
/**
* When constructing a new component, this takes care of basic tasks like
* setting up the Name Panel and assigning the class's static label as
* the name to start.
*/
public AbstractJMeterGuiComponent()
{
namePanel = new NamePanel();
setName(getStaticLabel());
}
/**
* Provides a default implementation for the name property. It's unlikely
* developers will need to override.
*/
public void setName(String name)
{
namePanel.setName(name);
}
/**
* Provides a default implementation for the enabled property. It's
* unlikely developers will need to override.
*/
public boolean isEnabled()
{
return enabled;
}
/**
* Provides a default implementation for the enabled property. It's
* unlikely developers will need to override.
*/
public void setEnabled(boolean e)
{
log.debug("Setting enabled: " + e);
enabled = e;
}
/**
* Provides a default implementation for the name property. It's unlikely
* developers will need to override.
*/
public String getName()
{
if (getNamePanel() != null) {
return getNamePanel().getName();
}
else return "";
}
/**
* Provides the Name Panel for extending classes. Extending classes are
* free to place it as desired within the component, or not at all. Most
* components place the NamePanel automatically by calling
* {@link #makeTitlePanel()} instead of directly calling this method.
*
* @return a NamePanel containing the name of this component
*/
protected NamePanel getNamePanel()
{
return namePanel;
}
/**
* Provides a label containing the title for the component. Subclasses
* typically place this label at the top of their GUI. The title is set
* to the name returned from the component's
* {@link JMeterGUIComponent#getStaticLabel() getStaticLabel()} method.
* Most components place this label automatically by calling
* {@link #makeTitlePanel()} instead of directly calling this method.
*
* @return a JLabel which subclasses can add to their GUI
*/
protected Component createTitleLabel()
{
JLabel titleLabel = new JLabel(getStaticLabel());
Font curFont = titleLabel.getFont();
titleLabel.setFont(curFont.deriveFont((float) curFont.getSize() + 4));
return titleLabel;
}
/**
* A newly created gui component can be initialized with the contents of
* a Test Element object by calling this method. The component is
* responsible for querying the Test Element object for the
* relevant information to display in its GUI.
*
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.