jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1226254 - /jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java
Date Sun, 01 Jan 2012 14:50:12 GMT
Author: pmouawad
Date: Sun Jan  1 14:50:12 2012
New Revision: 1226254

URL: http://svn.apache.org/viewvc?rev=1226254&view=rev
Log:
Factored out code with GaussianRandomTimerGui

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java?rev=1226254&r1=1226253&r2=1226254&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java Sun
Jan  1 14:50:12 2012
@@ -18,152 +18,75 @@
 
 package org.apache.jmeter.timers.gui;
 
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import org.apache.jmeter.gui.util.FocusRequester;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.timers.ConstantTimer;
 import org.apache.jmeter.timers.RandomTimer;
 import org.apache.jmeter.timers.UniformRandomTimer;
 import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.gui.layout.VerticalLayout;
 
 /**
  * Implementation of a uniform random timer.
  *
  */
-public class UniformRandomTimerGui extends AbstractTimerGui {
+public class UniformRandomTimerGui extends AbstractRandomTimerGui {
 
     private static final long serialVersionUID = 240L;
 
-    // TODO - are these gui item names needed?
-    private static final String DELAY_FIELD = "Delay Field";
-
-    private static final String RANGE_FIELD = "Range Field";
-
     private static final String DEFAULT_DELAY = "0"; // $NON-NLS-1$
 
     private static final String DEFAULT_RANGE = "100.0";// $NON-NLS-1$
 
-    private JTextField delayField;
-
-    private JTextField rangeField;
-
     /**
      * No-arg constructor.
      */
     public UniformRandomTimerGui() {
-        init();
+        super();
     }
 
+    
     /**
-     * Handle an error.
-     *
-     * @param e
-     *            the Exception that was thrown.
-     * @param thrower
-     *            the JComponent that threw the Exception.
+     * {@inheritDoc}
      */
-    public static void error(Exception e, JComponent thrower) {
-        JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
-    }
-
+    @Override
     public String getLabelResource() {
-        return "uniform_timer_title"; //$NON-NLS-1$
-    }
-
-    /**
-     * Create the test element underlying this GUI component.
-     *
-     * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
-     */
-    public TestElement createTestElement() {
-        RandomTimer timer = new UniformRandomTimer();
-        modifyTestElement(timer);
-        return timer;
-    }
-
-    /**
-     * Modifies a given TestElement to mirror the data in the gui components.
-     *
-     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
-     */
-    public void modifyTestElement(TestElement timer) {
-        this.configureTestElement(timer);
-        ((RandomTimer) timer).setDelay(delayField.getText());
-        ((RandomTimer) timer).setRange(rangeField.getText());
+    	return "uniform_timer_title";//$NON-NLS-1$
     }
 
     /**
-     * Configure this GUI component from the underlying TestElement.
-     *
-     * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+     * {@inheritDoc}
      */
-    @Override
-    public void configure(TestElement el) {
-        super.configure(el);
-        delayField.setText(el.getPropertyAsString(ConstantTimer.DELAY));
-        rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
-    }
+	@Override
+	protected RandomTimer createRandomTimer() {
+		return new UniformRandomTimer();
+	}
 
-    /**
-     * Initialize this component.
+	/**
+     * {@inheritDoc}
      */
-    private void init() {
-        setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
-        setBorder(makeBorder());
-
-        add(makeTitlePanel());
-
-        // THREAD DELAY PROPERTIES
-        JPanel threadDelayPropsPanel = new JPanel();
-        threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
-        threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils
-                .getResString("thread_delay_properties"))); //$NON-NLS-1$
-
-        // DELAY DEVIATION
-        Box delayDevPanel = Box.createHorizontalBox();
-        delayDevPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_range"))); //$NON-NLS-1$
-        delayDevPanel.add(Box.createHorizontalStrut(5));
-
-        rangeField = new JTextField(6);
-        rangeField.setText(DEFAULT_RANGE);
-        rangeField.setName(RANGE_FIELD);
-        delayDevPanel.add(rangeField);
-
-        threadDelayPropsPanel.add(delayDevPanel);
-
-        // AVG DELAY
-        Box avgDelayPanel = Box.createHorizontalBox();
-        avgDelayPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_delay"))); //$NON-NLS-1$
-        avgDelayPanel.add(Box.createHorizontalStrut(5));
-
-        delayField = new JTextField(6);
-        delayField.setText(DEFAULT_DELAY);
-        delayField.setName(DELAY_FIELD);
-        avgDelayPanel.add(delayField);
-
-        threadDelayPropsPanel.add(avgDelayPanel);
+	@Override
+	protected String getTimerDelayLabelKey() {
+		return JMeterUtils.getResString("uniform_timer_delay");
+	}
 
-        add(threadDelayPropsPanel);
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getTimerRangeLabelKey() {
+		return JMeterUtils.getResString("uniform_timer_range");
+	}
 
-        // Set the initial focus to the range field
-        new FocusRequester(rangeField);
-    }
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getDefaultDelay() {
+		return DEFAULT_DELAY;
+	}
 
-    /**
+	/**
      * {@inheritDoc}
      */
-    @Override
-    public void clearGui() {
-        rangeField.setText(DEFAULT_RANGE);
-        delayField.setText(DEFAULT_DELAY);
-        super.clearGui();
-    }
+	@Override
+	protected String getDefaultRange() {
+		return DEFAULT_RANGE;
+	}
 }



Mime
View raw message