001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.assertions.gui;
020:
021: import java.awt.BorderLayout;
022:
023: import javax.swing.BorderFactory;
024: import javax.swing.JLabel;
025: import javax.swing.JPanel;
026: import javax.swing.JTextField;
027:
028: import org.apache.jmeter.assertions.DurationAssertion;
029: import org.apache.jmeter.gui.util.VerticalPanel;
030: import org.apache.jmeter.testelement.TestElement;
031: import org.apache.jmeter.util.JMeterUtils;
032:
033: public class DurationAssertionGui extends AbstractAssertionGui {
034:
035: private JTextField duration;
036:
037: public DurationAssertionGui() {
038: init();
039: }
040:
041: public String getLabelResource() {
042: return "duration_assertion_title"; // $NON-NLS-1$
043: }
044:
045: public String getDurationAttributesTitle() {
046: return JMeterUtils
047: .getResString("duration_assertion_duration_test"); // $NON-NLS-1$
048: }
049:
050: public TestElement createTestElement() {
051: DurationAssertion el = new DurationAssertion();
052: modifyTestElement(el);
053: return el;
054: }
055:
056: /**
057: * Modifies a given TestElement to mirror the data in the gui components.
058: *
059: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
060: */
061: public void modifyTestElement(TestElement el) {
062: configureTestElement(el);
063: el.setProperty(DurationAssertion.DURATION_KEY, duration
064: .getText());
065: }
066:
067: /**
068: * Implements JMeterGUIComponent.clearGui
069: */
070: public void clearGui() {
071: super .clearGui();
072:
073: duration.setText(""); //$NON-NLS-1$
074: }
075:
076: public void configure(TestElement el) {
077: super .configure(el);
078: duration.setText(el
079: .getPropertyAsString(DurationAssertion.DURATION_KEY));
080: }
081:
082: private void init() {
083: setLayout(new BorderLayout(0, 10));
084: setBorder(makeBorder());
085:
086: add(makeTitlePanel(), BorderLayout.NORTH);
087:
088: JPanel mainPanel = new JPanel(new BorderLayout());
089:
090: // USER_INPUT
091: VerticalPanel durationPanel = new VerticalPanel();
092: durationPanel.setBorder(BorderFactory.createTitledBorder(
093: BorderFactory.createEtchedBorder(),
094: getDurationAttributesTitle()));
095:
096: JPanel labelPanel = new JPanel(new BorderLayout(5, 0));
097: JLabel durationLabel = new JLabel(JMeterUtils
098: .getResString("duration_assertion_label")); // $NON-NLS-1$
099: labelPanel.add(durationLabel, BorderLayout.WEST);
100:
101: duration = new JTextField();
102: labelPanel.add(duration, BorderLayout.CENTER);
103: durationLabel.setLabelFor(duration);
104: durationPanel.add(labelPanel);
105:
106: mainPanel.add(durationPanel, BorderLayout.NORTH);
107: add(mainPanel, BorderLayout.CENTER);
108: }
109: }
|