Package org.apache.jmeter.gui
Class AbstractJMeterGuiComponent
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.apache.jmeter.gui.AbstractJMeterGuiComponent
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,ClearGui,JMeterGUIComponent,Printable
- Direct Known Subclasses:
AbstractConfigGui,AbstractControllerGui,AbstractListenerGui,AbstractPreProcessorGui,AbstractSamplerGui,AbstractScopedJMeterGuiComponent,AbstractThreadGroupGui,AbstractTimerGui,ObsoleteGui,TestBeanGUI,TestPlanGui,WorkBenchGui
public abstract class AbstractJMeterGuiComponent
extends JPanel
implements JMeterGUIComponent, Printable
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).
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.jmeter.gui.BindingGroupStores a collection of property editors, so GuiCompoenent can have default implementations that update the UI fields based onTestElementproperties and vice versa.protected NamePanelDeprecated.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWhen 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. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearGui()Provides a default implementation that resets the name field to the value of getStaticLabel(), reset comment and sets enabled to true.voidconfigure(org.apache.jmeter.testelement.TestElement element) A newly created gui component can be initialized with the contents of a Test Element object by calling this method.protected voidconfigureTestElement(org.apache.jmeter.testelement.TestElement mc) This provides a convenience for extenders when they implement theJMeterGUIComponent.modifyTestElement(TestElement)method.protected ComponentProvides a label containing the title for the component.Provides a default implementation for the comment property.Compute Anchor value to find reference in documentation for a particular componentgetName()Provides a default implementation for the name property.protected NamePanelDeprecated.usegetName()orcreateTitleLabel()for better alignment of the fieldsSubclasses need to over-ride this method, if they wish to return something other than the Visualizer itself.Get the component's label.booleanProvides a default implementation for the enabled property.protected BorderCreate a top-level Border which can be added to JMeter components.protected JScrollPanemakeScrollPane(Component comp) Create a scroll panel that sets it's preferred size to it's minimum size.protected JScrollPanemakeScrollPane(Component comp, int verticalPolicy, int horizontalPolicy) Create a scroll panel that sets it's preferred size to it's minimum size.protected ContainerCreate a standard title section for JMeter components.voidmodifyTestElement(org.apache.jmeter.testelement.TestElement element) GUI components are responsible for populating TestElements they create with the data currently held in the GUI components.voidsetComment(String comment) Provides a default implementation for setting the comment property.voidsetEnabled(boolean enabled) Provides a default implementation for the enabled property.voidProvides a default implementation for setting the name property.protected ContainerwrapTitlePanel(Container titlePanel) Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.jmeter.gui.JMeterGUIComponent
assignDefaultValues, canBeAdded, createPopupMenu, createTestElement, getLabelResource, getMenuCategories, makeTestElement
-
Field Details
-
namePanel
Deprecated.usegetName()orcreateTitleLabel()for better alignment of the fieldsA GUI panel containing the name of this component. -
bindingGroup
@API(status=EXPERIMENTAL, since="5.6.3") protected final org.apache.jmeter.gui.BindingGroup bindingGroupStores a collection of property editors, so GuiCompoenent can have default implementations that update the UI fields based onTestElementproperties and vice versa.
-
-
Constructor Details
-
AbstractJMeterGuiComponent
protected AbstractJMeterGuiComponent()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.
-
-
Method Details
-
setName
Provides a default implementation for setting the name property. It's unlikely developers will need to override.- Specified by:
setNamein interfaceJMeterGUIComponent- Overrides:
setNamein classComponent- Parameters:
name- the name of the component
-
setComment
Provides a default implementation for setting the comment property. It's unlikely developers will need to override.- Parameters:
comment- The comment for the property
-
isEnabled
public boolean isEnabled()Provides a default implementation for the enabled property. It's unlikely developers will need to override.- Specified by:
isEnabledin interfaceJMeterGUIComponent- Overrides:
isEnabledin classComponent- Returns:
- true if the element should be part of the test run, false otherwise
-
setEnabled
public void setEnabled(boolean enabled) Provides a default implementation for the enabled property. It's unlikely developers will need to override.- Specified by:
setEnabledin interfaceJMeterGUIComponent- Overrides:
setEnabledin classJComponent- Parameters:
enabled- true for enabled, false for disabled.
-
getName
Provides a default implementation for the name property. It's unlikely developers will need to override.- Specified by:
getNamein interfaceJMeterGUIComponent- Overrides:
getNamein classComponent- Returns:
- the name of the component
-
getComment
Provides a default implementation for the comment property. It's unlikely developers will need to override.- Returns:
- The comment for the property
-
getNamePanel
Deprecated.usegetName()orcreateTitleLabel()for better alignment of the fieldsProvides 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 callingmakeTitlePanel()instead of directly calling this method.- Returns:
- a NamePanel containing the name of this component
-
createTitleLabel
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'sgetStaticLabel()method. Most components place this label automatically by callingmakeTitlePanel()instead of directly calling this method.- Returns:
- a JLabel which subclasses can add to their GUI
-
configure
public void configure(org.apache.jmeter.testelement.TestElement element) 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.AbstractJMeterGuiComponent provides a partial implementation of this method, setting the name of the component and its enabled status. Subclasses should override this method, performing their own configuration as needed, but also calling this super-implementation.
- Specified by:
configurein interfaceJMeterGUIComponent- Parameters:
element- the TestElement to configure
-
clearGui
public void clearGui()Provides a default implementation that resets the name field to the value of getStaticLabel(), reset comment and sets enabled to true. Your GUI may need more things cleared, in which case you should override, clear the extra fields, and still call super.clearGui(). -
modifyTestElement
@API(status=EXPERIMENTAL, since="5.6.3") public void modifyTestElement(org.apache.jmeter.testelement.TestElement element) Description copied from interface:JMeterGUIComponentGUI components are responsible for populating TestElements they create with the data currently held in the GUI components. This method should overwrite whatever data is currently in the TestElement as it is called after a user has filled out the form elements in the gui with new information.If you override
AbstractJMeterGuiComponent, you might want usingbindingGroupinstead of overridingmodifyTestElement.The canonical implementation looks like this:
@Override public void modifyTestElement(TestElement element) { super.modifyTestElement(element); // clear the element and assign basic fields like name, gui class, test class // Using the element setters (preferred): // If the field is empty, you probably want to remove the property instead of storing an empty string // See Streamline binding of UI elements to TestElement properties // for more details TestElementXYZ xyz = (TestElementXYZ) element; xyz.setState(StringUtils.defaultIfEmpty(guiState.getText(), null)); xyz.setCode(StringUtils.defaultIfEmpty(guiCode.getText(), null)); ... other GUI fields ... // or directly (do not use unless there is no setter for the field): element.setProperty(TestElementXYZ.STATE, StringUtils.defaultIfEmpty(guiState.getText(), null)) element.setProperty(TestElementXYZ.CODE, StringUtils.defaultIfEmpty(guiCode.getText(), null)) ... other GUI fields ... }- Specified by:
modifyTestElementin interfaceJMeterGUIComponent- Parameters:
element- the TestElement to modify
-
configureTestElement
@API(status=DEPRECATED, since="5.6.3") protected void configureTestElement(org.apache.jmeter.testelement.TestElement mc) This provides a convenience for extenders when they implement theJMeterGUIComponent.modifyTestElement(TestElement)method. This method will set the name, gui class, and test class for the created Test Element. It should be called by every extending class when creating/modifying Test Elements, as that will best assure consistent behavior.Deprecation notice: most likely you do not need the method, and you should override
modifyTestElement(TestElement)instead- Parameters:
mc- the TestElement being created.
-
makeTitlePanel
Create a standard title section for JMeter components. This includes the title for the component and the Name Panel allowing the user to change the name for the component. This method is typically added to the top of the component at the beginning of the component's init method.- Returns:
- a panel containing the component title and name panel
-
wrapTitlePanel
-
makeBorder
Create a top-level Border which can be added to JMeter components. Components typically set this as their border in their init method. It simply provides a nice spacing between the GUI components used and the edges of the window in which they appear.- Returns:
- a Border for JMeter components
-
makeScrollPane
Create a scroll panel that sets it's preferred size to it's minimum size. Explicitly for scroll panes that live inside other scroll panes, or within containers that stretch components to fill the area they exist in. Use this for any component you would put in a scroll pane (such as TextAreas, tables, JLists, etc). It is here for convenience and to avoid duplicate code. JMeter displays best if you follow this custom.- Parameters:
comp- the component which should be placed inside the scroll pane- Returns:
- a JScrollPane containing the specified component
-
makeScrollPane
Create a scroll panel that sets it's preferred size to it's minimum size. Explicitly for scroll panes that live inside other scroll panes, or within containers that stretch components to fill the area they exist in. Use this for any component you would put in a scroll pane (such as TextAreas, tables, JLists, etc). It is here for convenience and to avoid duplicate code. JMeter displays best if you follow this custom.- Parameters:
comp- the component which should be placed inside the scroll paneverticalPolicy- the vertical scroll policyhorizontalPolicy- the horizontal scroll policy- Returns:
- a JScrollPane containing the specified component
- See Also:
-
getStaticLabel
Description copied from interface:JMeterGUIComponentGet the component's label. This label is used in drop down lists that give the user the option of choosing one type of component in a list of many. It should therefore be a descriptive name for the end user to see. It must be unique to the class. It is also used by Help to find the appropriate location in the documentation. Normally getLabelResource() should be overridden instead of this method; the definition of this method in AbstractJMeterGuiComponent is intended for general use.- Specified by:
getStaticLabelin interfaceJMeterGUIComponent- Returns:
- GUI label for the component.
- See Also:
-
getDocAnchor
Compute Anchor value to find reference in documentation for a particular component- Specified by:
getDocAnchorin interfaceJMeterGUIComponent- Returns:
- String anchor
-
getPrintableComponent
Subclasses need to over-ride this method, if they wish to return something other than the Visualizer itself.- Specified by:
getPrintableComponentin interfacePrintable- Returns:
- this object
-
getName()orcreateTitleLabel()for better alignment of the fields