You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2005/11/27 02:01:59 UTC
svn commit: r349162 [1/3] - in /jakarta/jmeter/branches/rel-2-1:
src/components/org/apache/jmeter/assertions/
src/components/org/apache/jmeter/assertions/gui/
src/components/org/apache/jmeter/extractor/
src/components/org/apache/jmeter/extractor/gui/ s...
Author: sebb
Date: Sat Nov 26 17:01:05 2005
New Revision: 349162
URL: http://svn.apache.org/viewcvs?rev=349162&view=rev
Log:
Fix missing properties
Modified:
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/assertions/XMLSchemaAssertion.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/SyncTimer.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/XMLDefaultMutableTreeNode.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/testelement/ThreadListener.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/TreeTableModel.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactory.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/OrderPreservingLogParser.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/SharedTCLogParser.java (props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/gui/util/DirectoryDialoger.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/gui/util/DirectoryPanel.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportTable.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/assertions/PackageTest.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/assertions/XMLSchemaAssertionTest.java (props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/config/TestCVSDataSet.java (props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/testelement/BarChartTest.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/testelement/LineGraphTest.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/util/PackageTest.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jmeter/util/TestJMeterUtils.java (contents, props changed)
jakarta/jmeter/branches/rel-2-1/test/src/org/apache/jorphan/util/TestJorphanUtils.java (props changed)
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/assertions/XMLSchemaAssertion.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java Sat Nov 26 17:01:05 2005
@@ -1,197 +1,196 @@
-//$Header$
-/*
- * Copyright 2005 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.extractor;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-
-import org.apache.jmeter.processor.PostProcessor;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.jmeter.testelement.AbstractTestElement;
-import org.apache.jmeter.testelement.property.BooleanProperty;
-import org.apache.jmeter.threads.JMeterContext;
-import org.apache.jmeter.threads.JMeterVariables;
-import org.apache.jmeter.util.XPathUtil;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-import org.apache.xpath.XPathAPI;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-/**
- * Extracts text from (X)HTML response using XPath query language
- * Example XPath queries:
- * <dl>
- * <dt>/html/head/title</dt>
- * <dd>extracts Title from HTML response</dd>
- * <dt>//form[@name='countryForm']//select[@name='country']/option[text()='Czech Republic'])/@value
- * <dd>extracts value attribute of option element that match text 'Czech Republic'
- * inside of select element with name attribute 'country' inside of
- * form with name attribute 'countryForm'</dd>
- * </dl>
- */
- /* This file is inspired by RegexExtractor.
- * author <a href="mailto:hpaluch@gitus.cz">Henryk Paluch</a>
- * of <a href="http://www.gitus.com">Gitus a.s.</a>
- *
- * See Bugzilla: 37183
- */
-public class XPathExtractor extends AbstractTestElement implements
- PostProcessor, Serializable {
- transient private static Logger log = LoggingManager.getLoggerForClass();
- protected static final String KEY_PREFIX = "XPathExtractor.";
- public static final String XPATH_QUERY = KEY_PREFIX +"xpathQuery";
- public static final String REFNAME = KEY_PREFIX +"refname";
- public static final String DEFAULT = KEY_PREFIX +"default";
- public static final String TOLERANT = KEY_PREFIX +"tolerant";
-
-
- /**
- * Do the job - extract value from (X)HTML response using XPath Query.
- * Return value as variable defined by REFNAME. Returns DEFAULT value
- * if not found.
- */
- public void process() {
- JMeterContext context = getThreadContext();
- JMeterVariables vars = context.getVariables();
- String refName = getRefName();
- vars.put(refName, getDefaultValue());
-
- try{
- Document d = parseResponse(context.getPreviousResult());
- String val = getValueForXPath(d,getXPathQuery());
- if ( val!=null){
- vars.put(getRefName(),val);
- }
- }catch(IOException e){
- log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
- throw new RuntimeException(e);
- } catch (ParserConfigurationException e) {
- log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
- throw new RuntimeException(e);
- } catch (SAXException e) {
- log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
- throw new RuntimeException(e);
- } catch (TransformerException e) {
- log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Clone?
- */
- public Object clone() {
- XPathExtractor cloned = (XPathExtractor) super.clone();
- return cloned;
- }
-
- /*============= object properties ================*/
- public void setXPathQuery(String val){
- setProperty(XPATH_QUERY,val);
- }
-
- public String getXPathQuery(){
- return getPropertyAsString(XPATH_QUERY);
- }
-
- public void setRefName(String refName) {
- setProperty(REFNAME, refName);
- }
-
- public String getRefName() {
- return getPropertyAsString(REFNAME);
- }
-
- public void setDefaultValue(String val) {
- setProperty(DEFAULT, val);
- }
-
- public String getDefaultValue() {
- return getPropertyAsString(DEFAULT);
- }
-
- public void setTolerant(boolean val) {
- setProperty(new BooleanProperty(TOLERANT, val));
- }
-
- public boolean isTolerant() {
- return getPropertyAsBoolean(TOLERANT);
- }
-
- /*================= internal business =================*/
- /**
- * Converts (X)HTML response to DOM object Tree.
- * This version cares of charset of response.
- * @param result
- * @return
- *
- */
- private Document parseResponse(SampleResult result)
- throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException
- {
- //TODO: validate contentType for reasonable types?
-
- // NOTE: responseData encoding is server specific
- // Therefore we do byte -> unicode -> byte conversion
- // to ensure UTF-8 encoding as required by XPathUtil
- String unicodeData = new String(result.getResponseData(),
- result.getDataEncoding());
- // convert unicode String -> UTF-8 bytes
- byte[] utf8data = unicodeData.getBytes("UTF-8");
- ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
- // this method assumes UTF-8 input data
- return XPathUtil.makeDocument(in,false,false,false,isTolerant());
- }
-
- /**
- * Extract value from Document d by XPath query.
- * @param d
- * @param query
- * @return extracted value (even empty string) or null if queried
- * data were not found
- * @throws TransformerException
- */
- private String getValueForXPath(Document d,String query)
- throws TransformerException
- {
- String val = null;
- Node match = XPathAPI.selectSingleNode(d,query);
- if ( match!=null){
- if ( match instanceof Element){
- // elements have empty nodeValue, but we are usually
- // interested in their content
- val = match.getFirstChild().getNodeValue();
- } else {
- val = match.getNodeValue();
- }
- }
- if ( log.isDebugEnabled()){
- log.debug(XPATH_QUERY+"("+query+") is '"+val+"'");
- }
- return val;
- }
-
-}
+/*
+ * Copyright 2005 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.extractor;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.jmeter.processor.PostProcessor;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.testelement.property.BooleanProperty;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jmeter.util.XPathUtil;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.apache.xpath.XPathAPI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * Extracts text from (X)HTML response using XPath query language
+ * Example XPath queries:
+ * <dl>
+ * <dt>/html/head/title</dt>
+ * <dd>extracts Title from HTML response</dd>
+ * <dt>//form[@name='countryForm']//select[@name='country']/option[text()='Czech Republic'])/@value
+ * <dd>extracts value attribute of option element that match text 'Czech Republic'
+ * inside of select element with name attribute 'country' inside of
+ * form with name attribute 'countryForm'</dd>
+ * </dl>
+ */
+ /* This file is inspired by RegexExtractor.
+ * author <a href="mailto:hpaluch@gitus.cz">Henryk Paluch</a>
+ * of <a href="http://www.gitus.com">Gitus a.s.</a>
+ *
+ * See Bugzilla: 37183
+ */
+public class XPathExtractor extends AbstractTestElement implements
+ PostProcessor, Serializable {
+ transient private static Logger log = LoggingManager.getLoggerForClass();
+ protected static final String KEY_PREFIX = "XPathExtractor.";
+ public static final String XPATH_QUERY = KEY_PREFIX +"xpathQuery";
+ public static final String REFNAME = KEY_PREFIX +"refname";
+ public static final String DEFAULT = KEY_PREFIX +"default";
+ public static final String TOLERANT = KEY_PREFIX +"tolerant";
+
+
+ /**
+ * Do the job - extract value from (X)HTML response using XPath Query.
+ * Return value as variable defined by REFNAME. Returns DEFAULT value
+ * if not found.
+ */
+ public void process() {
+ JMeterContext context = getThreadContext();
+ JMeterVariables vars = context.getVariables();
+ String refName = getRefName();
+ vars.put(refName, getDefaultValue());
+
+ try{
+ Document d = parseResponse(context.getPreviousResult());
+ String val = getValueForXPath(d,getXPathQuery());
+ if ( val!=null){
+ vars.put(getRefName(),val);
+ }
+ }catch(IOException e){
+ log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
+ throw new RuntimeException(e);
+ } catch (ParserConfigurationException e) {
+ log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
+ throw new RuntimeException(e);
+ } catch (TransformerException e) {
+ log.error("error on "+XPATH_QUERY+"("+getXPathQuery()+")",e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Clone?
+ */
+ public Object clone() {
+ XPathExtractor cloned = (XPathExtractor) super.clone();
+ return cloned;
+ }
+
+ /*============= object properties ================*/
+ public void setXPathQuery(String val){
+ setProperty(XPATH_QUERY,val);
+ }
+
+ public String getXPathQuery(){
+ return getPropertyAsString(XPATH_QUERY);
+ }
+
+ public void setRefName(String refName) {
+ setProperty(REFNAME, refName);
+ }
+
+ public String getRefName() {
+ return getPropertyAsString(REFNAME);
+ }
+
+ public void setDefaultValue(String val) {
+ setProperty(DEFAULT, val);
+ }
+
+ public String getDefaultValue() {
+ return getPropertyAsString(DEFAULT);
+ }
+
+ public void setTolerant(boolean val) {
+ setProperty(new BooleanProperty(TOLERANT, val));
+ }
+
+ public boolean isTolerant() {
+ return getPropertyAsBoolean(TOLERANT);
+ }
+
+ /*================= internal business =================*/
+ /**
+ * Converts (X)HTML response to DOM object Tree.
+ * This version cares of charset of response.
+ * @param result
+ * @return
+ *
+ */
+ private Document parseResponse(SampleResult result)
+ throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException
+ {
+ //TODO: validate contentType for reasonable types?
+
+ // NOTE: responseData encoding is server specific
+ // Therefore we do byte -> unicode -> byte conversion
+ // to ensure UTF-8 encoding as required by XPathUtil
+ String unicodeData = new String(result.getResponseData(),
+ result.getDataEncoding());
+ // convert unicode String -> UTF-8 bytes
+ byte[] utf8data = unicodeData.getBytes("UTF-8");
+ ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
+ // this method assumes UTF-8 input data
+ return XPathUtil.makeDocument(in,false,false,false,isTolerant());
+ }
+
+ /**
+ * Extract value from Document d by XPath query.
+ * @param d
+ * @param query
+ * @return extracted value (even empty string) or null if queried
+ * data were not found
+ * @throws TransformerException
+ */
+ private String getValueForXPath(Document d,String query)
+ throws TransformerException
+ {
+ String val = null;
+ Node match = XPathAPI.selectSingleNode(d,query);
+ if ( match!=null){
+ if ( match instanceof Element){
+ // elements have empty nodeValue, but we are usually
+ // interested in their content
+ val = match.getFirstChild().getNodeValue();
+ } else {
+ val = match.getNodeValue();
+ }
+ }
+ if ( log.isDebugEnabled()){
+ log.debug(XPATH_QUERY+"("+query+") is '"+val+"'");
+ }
+ return val;
+ }
+
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/XPathExtractor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java Sat Nov 26 17:01:05 2005
@@ -1,144 +1,144 @@
-/*
- * Copyright 2005 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.extractor.gui;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.util.List;
-
-import javax.swing.Box;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-
-import org.apache.jmeter.extractor.XPathExtractor;
-import org.apache.jmeter.processor.gui.AbstractPostProcessorGui;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.gui.JLabeledTextField;
-/**
- * GUI for XPathExtractor class.
- */
- /* This file is inspired by RegexExtractor.
- * author <a href="mailto:hpaluch@gitus.cz">Henryk Paluch</a>
- * of <a href="http://www.gitus.com">Gitus a.s.</a>
- * See Bugzilla: 37183
- */
-public class XPathExtractorGui extends AbstractPostProcessorGui {
-
- private JLabeledTextField defaultField;
-
- private JLabeledTextField xpathQueryField;
-
- private JLabeledTextField refNameField;
-
- private JCheckBox tolerant;
-
- public String getLabelResource() {
- return "xpath_extractor_title";
- }
-
- public XPathExtractorGui(){
- super();
- init();
- }
-
- public void configure(TestElement el) {
- super.configure(el);
- xpathQueryField.setText(el.getPropertyAsString(XPathExtractor.XPATH_QUERY));
- defaultField.setText(el.getPropertyAsString(XPathExtractor.DEFAULT));
- refNameField.setText(el.getPropertyAsString(XPathExtractor.REFNAME));
- tolerant.setSelected(el.getPropertyAsBoolean(XPathExtractor.TOLERANT));
- }
-
-
- public TestElement createTestElement() {
- XPathExtractor extractor = new XPathExtractor();
- modifyTestElement(extractor);
- return extractor;
- }
-
- /* (non-Javadoc)
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
- */
- public void modifyTestElement(TestElement extractor) {
- super.configureTestElement(extractor);
- if ( extractor instanceof XPathExtractor){
- XPathExtractor xpath = (XPathExtractor)extractor;
- xpath.setDefaultValue(defaultField.getText());
- xpath.setRefName(refNameField.getText());
- xpath.setXPathQuery(xpathQueryField.getText());
- xpath.setTolerant(tolerant.isSelected());
- }
- }
-
- private void init() {
- setLayout(new BorderLayout());
- setBorder(makeBorder());
-
- Box box = Box.createVerticalBox();
- box.add(makeTitlePanel());
- tolerant = new JCheckBox(JMeterUtils.getResString("xpath_extractor_tolerant"));
- box.add(tolerant);
- add(box, BorderLayout.NORTH);
- add(makeParameterPanel(), BorderLayout.CENTER);
- }
-
-
- private JPanel makeParameterPanel() {
- xpathQueryField = new JLabeledTextField(JMeterUtils.getResString("xpath_extractor_query"));
- defaultField = new JLabeledTextField(JMeterUtils.getResString("default_value_field"));
- refNameField = new JLabeledTextField(JMeterUtils.getResString("ref_name_field"));
-
- JPanel panel = new JPanel(new GridBagLayout());
- GridBagConstraints gbc = new GridBagConstraints();
- initConstraints(gbc);
- addField(panel, refNameField, gbc);
- resetContraints(gbc);
- addField(panel, xpathQueryField, gbc);
- resetContraints(gbc);
- gbc.weighty = 1;
- addField(panel, defaultField, gbc);
- return panel;
- }
-
- private void addField(JPanel panel, JLabeledTextField field, GridBagConstraints gbc) {
- List item = field.getComponentList();
- panel.add((Component) item.get(0), gbc.clone());
- gbc.gridx++;
- gbc.weightx = 1;
- panel.add((Component) item.get(1), gbc.clone());
- }
-
- private void resetContraints(GridBagConstraints gbc) {
- gbc.gridx = 0;
- gbc.gridy++;
- gbc.weightx = 0;
- }
-
- private void initConstraints(GridBagConstraints gbc) {
- gbc.anchor = GridBagConstraints.NORTHWEST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.gridheight = 1;
- gbc.gridwidth = 1;
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 0;
- gbc.weighty = 0;
- }
+/*
+ * Copyright 2005 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.extractor.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.List;
+
+import javax.swing.Box;
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+
+import org.apache.jmeter.extractor.XPathExtractor;
+import org.apache.jmeter.processor.gui.AbstractPostProcessorGui;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+/**
+ * GUI for XPathExtractor class.
+ */
+ /* This file is inspired by RegexExtractor.
+ * author <a href="mailto:hpaluch@gitus.cz">Henryk Paluch</a>
+ * of <a href="http://www.gitus.com">Gitus a.s.</a>
+ * See Bugzilla: 37183
+ */
+public class XPathExtractorGui extends AbstractPostProcessorGui {
+
+ private JLabeledTextField defaultField;
+
+ private JLabeledTextField xpathQueryField;
+
+ private JLabeledTextField refNameField;
+
+ private JCheckBox tolerant;
+
+ public String getLabelResource() {
+ return "xpath_extractor_title";
+ }
+
+ public XPathExtractorGui(){
+ super();
+ init();
+ }
+
+ public void configure(TestElement el) {
+ super.configure(el);
+ xpathQueryField.setText(el.getPropertyAsString(XPathExtractor.XPATH_QUERY));
+ defaultField.setText(el.getPropertyAsString(XPathExtractor.DEFAULT));
+ refNameField.setText(el.getPropertyAsString(XPathExtractor.REFNAME));
+ tolerant.setSelected(el.getPropertyAsBoolean(XPathExtractor.TOLERANT));
+ }
+
+
+ public TestElement createTestElement() {
+ XPathExtractor extractor = new XPathExtractor();
+ modifyTestElement(extractor);
+ return extractor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
+ */
+ public void modifyTestElement(TestElement extractor) {
+ super.configureTestElement(extractor);
+ if ( extractor instanceof XPathExtractor){
+ XPathExtractor xpath = (XPathExtractor)extractor;
+ xpath.setDefaultValue(defaultField.getText());
+ xpath.setRefName(refNameField.getText());
+ xpath.setXPathQuery(xpathQueryField.getText());
+ xpath.setTolerant(tolerant.isSelected());
+ }
+ }
+
+ private void init() {
+ setLayout(new BorderLayout());
+ setBorder(makeBorder());
+
+ Box box = Box.createVerticalBox();
+ box.add(makeTitlePanel());
+ tolerant = new JCheckBox(JMeterUtils.getResString("xpath_extractor_tolerant"));
+ box.add(tolerant);
+ add(box, BorderLayout.NORTH);
+ add(makeParameterPanel(), BorderLayout.CENTER);
+ }
+
+
+ private JPanel makeParameterPanel() {
+ xpathQueryField = new JLabeledTextField(JMeterUtils.getResString("xpath_extractor_query"));
+ defaultField = new JLabeledTextField(JMeterUtils.getResString("default_value_field"));
+ refNameField = new JLabeledTextField(JMeterUtils.getResString("ref_name_field"));
+
+ JPanel panel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+ initConstraints(gbc);
+ addField(panel, refNameField, gbc);
+ resetContraints(gbc);
+ addField(panel, xpathQueryField, gbc);
+ resetContraints(gbc);
+ gbc.weighty = 1;
+ addField(panel, defaultField, gbc);
+ return panel;
+ }
+
+ private void addField(JPanel panel, JLabeledTextField field, GridBagConstraints gbc) {
+ List item = field.getComponentList();
+ panel.add((Component) item.get(0), gbc.clone());
+ gbc.gridx++;
+ gbc.weightx = 1;
+ panel.add((Component) item.get(1), gbc.clone());
+ }
+
+ private void resetContraints(GridBagConstraints gbc) {
+ gbc.gridx = 0;
+ gbc.gridy++;
+ gbc.weightx = 0;
+ }
+
+ private void initConstraints(GridBagConstraints gbc) {
+ gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.gridheight = 1;
+ gbc.gridwidth = 1;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.weightx = 0;
+ gbc.weighty = 0;
+ }
}
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/SyncTimer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java Sat Nov 26 17:01:05 2005
@@ -1,254 +1,254 @@
-// $Header$
-/*
- * Copyright 2005 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.visualizers;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.LayoutManager;
-import java.awt.Paint;
-import java.awt.Shape;
-import java.awt.Stroke;
-
-import javax.swing.JPanel;
-
-import org.jCharts.axisChart.AxisChart;
-import org.jCharts.chartData.AxisChartDataSet;
-import org.jCharts.chartData.DataSeries;
-import org.jCharts.properties.AxisProperties;
-import org.jCharts.properties.ChartProperties;
-import org.jCharts.properties.DataAxisProperties;
-import org.jCharts.properties.LegendProperties;
-import org.jCharts.properties.LineChartProperties;
-import org.jCharts.properties.PointChartProperties;
-import org.jCharts.types.ChartType;
-
-/**
- *
- * Axis graph is used by StatGraphVisualizer, which generates bar graphs
- * from the statistical data.
- */
-public class LineGraph extends JPanel {
-
- protected double[][] data = null;
- protected String title, xAxisTitle, yAxisTitle;
- protected String[] xAxisLabels, yAxisLabel;
- protected int width, height;
-
- public static final Shape[] SHAPE_ARRAY = {PointChartProperties.SHAPE_CIRCLE,
- PointChartProperties.SHAPE_DIAMOND,PointChartProperties.SHAPE_SQUARE,
- PointChartProperties.SHAPE_TRIANGLE};
-
- /**
- * 12 basic colors for line graphs. If we need more colors than this,
- * we can add more. Though more than 12 lines per graph will look
- * rather busy and be hard to read.
- */
- public static final Paint[] PAINT_ARRAY = {Color.BLACK,
- Color.BLUE,Color.GREEN,Color.MAGENTA,Color.ORANGE,
- Color.RED,Color.YELLOW,Color.DARK_GRAY,Color.GRAY,Color.LIGHT_GRAY,
- Color.PINK,Color.CYAN};
- protected int shape_counter = 0;
- protected int paint_counter = -1;
-
- /**
- *
- */
- public LineGraph() {
- super();
- }
-
- /**
- * @param layout
- */
- public LineGraph(LayoutManager layout) {
- super(layout);
- }
-
- /**
- * @param layout
- * @param isDoubleBuffered
- */
- public LineGraph(LayoutManager layout, boolean isDoubleBuffered) {
- super(layout, isDoubleBuffered);
- }
-
- public void setData(double[][] data) {
- this.data = data;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void setXAxisTitle(String title) {
- this.xAxisTitle = title;
- }
-
- public void setYAxisTitle(String title) {
- this.yAxisTitle = title;
- }
-
- public void setXAxisLabels(String[] labels) {
- this.xAxisLabels = labels;
- }
-
- public void setYAxisLabels(String[] label) {
- this.yAxisLabel = label;
- }
-
- public void setWidth(int w) {
- this.width = w;
- }
-
- public void setHeight(int h) {
- this.height = h;
- }
-
- public void paintComponent(Graphics g) {
- // reset the paint counter
- this.paint_counter = -1;
- if (data != null && this.title != null && this.xAxisLabels != null &&
- this.xAxisTitle != null && this.yAxisLabel != null &&
- this.yAxisTitle != null) {
- drawSample(this.title,this.xAxisLabels,this.xAxisTitle,
- this.yAxisTitle,this.data,this.width,this.height,g);
- }
- }
-
- private void drawSample(String title, String[] xAxisLabels, String xAxisTitle,
- String yAxisTitle, double[][] data, int width, int height, Graphics g) {
- try {
- if (width == 0) {
- width = 450;
- }
- if (height == 0) {
- height = 250;
- }
- this.setPreferredSize(new Dimension(width,height));
- DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title );
- String[] legendLabels= yAxisLabel;
- Paint[] paints = this.createPaint(data.length);
- Shape[] shapes = createShapes(data.length);
- Stroke[] lstrokes = createStrokes(data.length);
- LineChartProperties lineChartProperties= new LineChartProperties(lstrokes,shapes);
- AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data,
- legendLabels,
- paints,
- ChartType.LINE,
- lineChartProperties );
- dataSeries.addIAxisPlotDataSet( axisChartDataSet );
-
- ChartProperties chartProperties = new ChartProperties();
- AxisProperties axisProperties = new AxisProperties();
- // show the grid lines, to turn it off, set it to zero
- axisProperties.getYAxisProperties().setShowGridLines(1);
- axisProperties.setXAxisLabelsAreVertical(true);
- // set the Y Axis to round
- DataAxisProperties daxp = (DataAxisProperties)axisProperties.getYAxisProperties();
- daxp.setRoundToNearest(1);
- LegendProperties legendProperties = new LegendProperties();
- AxisChart axisChart = new AxisChart(
- dataSeries, chartProperties, axisProperties,
- legendProperties, width, height );
- axisChart.setGraphics2D((Graphics2D) g);
- axisChart.render();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Since we only have 4 shapes, the method will start with the
- * first shape and keep cycling through the shapes in order.
- * @param count
- * @return
- */
- public Shape[] createShapes(int count) {
- Shape[] shapes = new Shape[count];
- for (int idx=0; idx < count; idx++) {
- shapes[idx] = nextShape();
- }
- return shapes;
- }
-
- /**
- * Return the next shape
- * @return
- */
- public Shape nextShape() {
- this.shape_counter++;
- if (shape_counter >= (SHAPE_ARRAY.length - 1)) {
- shape_counter = 0;
- }
- return SHAPE_ARRAY[shape_counter];
- }
-
- /**
- *
- * @param count
- * @return
- */
- public Stroke[] createStrokes(int count) {
- Stroke[] str = new Stroke[count];
- for (int idx=0; idx < count; idx++) {
- str[idx] = nextStroke();
- }
- return str;
- }
-
- /**
- * method always return a new BasicStroke with 1.0f weight
- * @return
- */
- public Stroke nextStroke() {
- return new BasicStroke(1.0f);
- }
-
- /**
- * return an array of Paint with different colors. The current
- * implementation will cycle through 12 colors if a line graph
- * has more than 12 entries
- * @param count
- * @return
- */
- public Paint[] createPaint(int count) {
- Paint[] pts = new Paint[count];
- for (int idx=0; idx < count; idx++) {
- pts[idx] = nextPaint();
- }
- return pts;
- }
-
- /**
- * The method will return the next paint color in the PAINT_ARRAY.
- * Rather than return a random color, we want it to always go through
- * the same sequence. This way, the same charts will always use the
- * same color and make it easier to compare side by side.
- * @return
- */
- public Paint nextPaint() {
- this.paint_counter++;
- if (this.paint_counter == (PAINT_ARRAY.length - 1)) {
- this.paint_counter = 0;
- }
- return PAINT_ARRAY[this.paint_counter];
- }
-}
+// $Header$
+/*
+ * Copyright 2005 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.visualizers;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.LayoutManager;
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+
+import javax.swing.JPanel;
+
+import org.jCharts.axisChart.AxisChart;
+import org.jCharts.chartData.AxisChartDataSet;
+import org.jCharts.chartData.DataSeries;
+import org.jCharts.properties.AxisProperties;
+import org.jCharts.properties.ChartProperties;
+import org.jCharts.properties.DataAxisProperties;
+import org.jCharts.properties.LegendProperties;
+import org.jCharts.properties.LineChartProperties;
+import org.jCharts.properties.PointChartProperties;
+import org.jCharts.types.ChartType;
+
+/**
+ *
+ * Axis graph is used by StatGraphVisualizer, which generates bar graphs
+ * from the statistical data.
+ */
+public class LineGraph extends JPanel {
+
+ protected double[][] data = null;
+ protected String title, xAxisTitle, yAxisTitle;
+ protected String[] xAxisLabels, yAxisLabel;
+ protected int width, height;
+
+ public static final Shape[] SHAPE_ARRAY = {PointChartProperties.SHAPE_CIRCLE,
+ PointChartProperties.SHAPE_DIAMOND,PointChartProperties.SHAPE_SQUARE,
+ PointChartProperties.SHAPE_TRIANGLE};
+
+ /**
+ * 12 basic colors for line graphs. If we need more colors than this,
+ * we can add more. Though more than 12 lines per graph will look
+ * rather busy and be hard to read.
+ */
+ public static final Paint[] PAINT_ARRAY = {Color.BLACK,
+ Color.BLUE,Color.GREEN,Color.MAGENTA,Color.ORANGE,
+ Color.RED,Color.YELLOW,Color.DARK_GRAY,Color.GRAY,Color.LIGHT_GRAY,
+ Color.PINK,Color.CYAN};
+ protected int shape_counter = 0;
+ protected int paint_counter = -1;
+
+ /**
+ *
+ */
+ public LineGraph() {
+ super();
+ }
+
+ /**
+ * @param layout
+ */
+ public LineGraph(LayoutManager layout) {
+ super(layout);
+ }
+
+ /**
+ * @param layout
+ * @param isDoubleBuffered
+ */
+ public LineGraph(LayoutManager layout, boolean isDoubleBuffered) {
+ super(layout, isDoubleBuffered);
+ }
+
+ public void setData(double[][] data) {
+ this.data = data;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setXAxisTitle(String title) {
+ this.xAxisTitle = title;
+ }
+
+ public void setYAxisTitle(String title) {
+ this.yAxisTitle = title;
+ }
+
+ public void setXAxisLabels(String[] labels) {
+ this.xAxisLabels = labels;
+ }
+
+ public void setYAxisLabels(String[] label) {
+ this.yAxisLabel = label;
+ }
+
+ public void setWidth(int w) {
+ this.width = w;
+ }
+
+ public void setHeight(int h) {
+ this.height = h;
+ }
+
+ public void paintComponent(Graphics g) {
+ // reset the paint counter
+ this.paint_counter = -1;
+ if (data != null && this.title != null && this.xAxisLabels != null &&
+ this.xAxisTitle != null && this.yAxisLabel != null &&
+ this.yAxisTitle != null) {
+ drawSample(this.title,this.xAxisLabels,this.xAxisTitle,
+ this.yAxisTitle,this.data,this.width,this.height,g);
+ }
+ }
+
+ private void drawSample(String title, String[] xAxisLabels, String xAxisTitle,
+ String yAxisTitle, double[][] data, int width, int height, Graphics g) {
+ try {
+ if (width == 0) {
+ width = 450;
+ }
+ if (height == 0) {
+ height = 250;
+ }
+ this.setPreferredSize(new Dimension(width,height));
+ DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title );
+ String[] legendLabels= yAxisLabel;
+ Paint[] paints = this.createPaint(data.length);
+ Shape[] shapes = createShapes(data.length);
+ Stroke[] lstrokes = createStrokes(data.length);
+ LineChartProperties lineChartProperties= new LineChartProperties(lstrokes,shapes);
+ AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data,
+ legendLabels,
+ paints,
+ ChartType.LINE,
+ lineChartProperties );
+ dataSeries.addIAxisPlotDataSet( axisChartDataSet );
+
+ ChartProperties chartProperties = new ChartProperties();
+ AxisProperties axisProperties = new AxisProperties();
+ // show the grid lines, to turn it off, set it to zero
+ axisProperties.getYAxisProperties().setShowGridLines(1);
+ axisProperties.setXAxisLabelsAreVertical(true);
+ // set the Y Axis to round
+ DataAxisProperties daxp = (DataAxisProperties)axisProperties.getYAxisProperties();
+ daxp.setRoundToNearest(1);
+ LegendProperties legendProperties = new LegendProperties();
+ AxisChart axisChart = new AxisChart(
+ dataSeries, chartProperties, axisProperties,
+ legendProperties, width, height );
+ axisChart.setGraphics2D((Graphics2D) g);
+ axisChart.render();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Since we only have 4 shapes, the method will start with the
+ * first shape and keep cycling through the shapes in order.
+ * @param count
+ * @return
+ */
+ public Shape[] createShapes(int count) {
+ Shape[] shapes = new Shape[count];
+ for (int idx=0; idx < count; idx++) {
+ shapes[idx] = nextShape();
+ }
+ return shapes;
+ }
+
+ /**
+ * Return the next shape
+ * @return
+ */
+ public Shape nextShape() {
+ this.shape_counter++;
+ if (shape_counter >= (SHAPE_ARRAY.length - 1)) {
+ shape_counter = 0;
+ }
+ return SHAPE_ARRAY[shape_counter];
+ }
+
+ /**
+ *
+ * @param count
+ * @return
+ */
+ public Stroke[] createStrokes(int count) {
+ Stroke[] str = new Stroke[count];
+ for (int idx=0; idx < count; idx++) {
+ str[idx] = nextStroke();
+ }
+ return str;
+ }
+
+ /**
+ * method always return a new BasicStroke with 1.0f weight
+ * @return
+ */
+ public Stroke nextStroke() {
+ return new BasicStroke(1.0f);
+ }
+
+ /**
+ * return an array of Paint with different colors. The current
+ * implementation will cycle through 12 colors if a line graph
+ * has more than 12 entries
+ * @param count
+ * @return
+ */
+ public Paint[] createPaint(int count) {
+ Paint[] pts = new Paint[count];
+ for (int idx=0; idx < count; idx++) {
+ pts[idx] = nextPaint();
+ }
+ return pts;
+ }
+
+ /**
+ * The method will return the next paint color in the PAINT_ARRAY.
+ * Rather than return a random color, we want it to always go through
+ * the same sequence. This way, the same charts will always use the
+ * same color and make it easier to compare side by side.
+ * @return
+ */
+ public Paint nextPaint() {
+ this.paint_counter++;
+ if (this.paint_counter == (PAINT_ARRAY.length - 1)) {
+ this.paint_counter = 0;
+ }
+ return PAINT_ARRAY[this.paint_counter];
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/LineGraph.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/visualizers/XMLDefaultMutableTreeNode.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java Sat Nov 26 17:01:05 2005
@@ -1,86 +1,86 @@
-/*
- * Copyright 2005 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.samplers;
-
-import java.io.Serializable;
-
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-/**
- * @author Lars Krog-Jensen
- * Created: 2005-okt-04
- */
-public class StatisticalSampleResult extends SampleResult implements
- Serializable {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- private int errorCount;
-
- public StatisticalSampleResult(){
- log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
- }
-
- public StatisticalSampleResult(SampleResult res) {
- setSampleLabel(res.getSampleLabel());
- }
-
- public void add(SampleResult res) {
- // Add Sample Counter
- setSampleCount(getSampleCount() + res.getSampleCount());
-
- // Add bytes
- int bytesLength = 0;
- // in case the sampler doesn't return the contents
- // we see if the bytes was set
- if (res.getResponseData() == null || res.getResponseData().length == 0) {
- bytesLength = res.getBytes();
- } else {
- bytesLength = res.getResponseData().length;
- }
- setBytes(getBytes() + bytesLength);
-
- // Add Error Counter
- if (!res.isSuccessful()) {
- errorCount++;
- }
-
- // Set start/end times
- this.setStartTime(Math.min(getStartTime(), res.getStartTime()));
- this.setEndTime(Math.max(getEndTime(), res.getEndTime()));
- }
-
- public long getTime() {
- return getEndTime() - getStartTime() - this.getIdleTime();
- }
-
- public long getTimeStamp() {
- return getEndTime();
- }
-
- public int getErrorCount() {
- return errorCount;
- }
-
- public static String getKey(SampleEvent event) {
- String key = event.getResult().getSampleLabel() + "-"
- + event.getThreadGroup();
-
- return key;
- }
-}
+/*
+ * Copyright 2005 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.samplers;
+
+import java.io.Serializable;
+
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * @author Lars Krog-Jensen
+ * Created: 2005-okt-04
+ */
+public class StatisticalSampleResult extends SampleResult implements
+ Serializable {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private int errorCount;
+
+ public StatisticalSampleResult(){
+ log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
+ }
+
+ public StatisticalSampleResult(SampleResult res) {
+ setSampleLabel(res.getSampleLabel());
+ }
+
+ public void add(SampleResult res) {
+ // Add Sample Counter
+ setSampleCount(getSampleCount() + res.getSampleCount());
+
+ // Add bytes
+ int bytesLength = 0;
+ // in case the sampler doesn't return the contents
+ // we see if the bytes was set
+ if (res.getResponseData() == null || res.getResponseData().length == 0) {
+ bytesLength = res.getBytes();
+ } else {
+ bytesLength = res.getResponseData().length;
+ }
+ setBytes(getBytes() + bytesLength);
+
+ // Add Error Counter
+ if (!res.isSuccessful()) {
+ errorCount++;
+ }
+
+ // Set start/end times
+ this.setStartTime(Math.min(getStartTime(), res.getStartTime()));
+ this.setEndTime(Math.max(getEndTime(), res.getEndTime()));
+ }
+
+ public long getTime() {
+ return getEndTime() - getStartTime() - this.getIdleTime();
+ }
+
+ public long getTimeStamp() {
+ return getEndTime();
+ }
+
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ public static String getKey(SampleEvent event) {
+ String key = event.getResult().getSampleLabel() + "-"
+ + event.getThreadGroup();
+
+ return key;
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java Sat Nov 26 17:01:05 2005
@@ -1,186 +1,186 @@
-/*
- * Copyright 2005 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.samplers;
-
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-import java.io.Serializable;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Implements batch reporting for remote testing.
- *
- * @author Lars Krog-Jensen
- * Created: 2005-okt-04
- */
-public class StatisticalSampleSender implements SampleSender, Serializable {
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- private static final int DEFAULT_NUM_SAMPLE_THRESHOLD = 100;
-
- private static final long DEFAULT_TIME_THRESHOLD = 60000L;
-
- private RemoteSampleListener listener;
-
- private List sampleStore = new ArrayList();
-
- private Map sampleTable = new HashMap();
-
- private int numSamplesThreshold;
-
- private int sampleCount;
-
- private long timeThreshold;
-
- private long batchSendTime = -1;
-
- public StatisticalSampleSender(){
- log.warn("Constructor only intended for use in testing");
- }
-
-
- /**
- * Constructor
- *
- * @param listener that the List of sample events will be sent to.
- */
- StatisticalSampleSender(RemoteSampleListener listener) {
- this.listener = listener;
- init();
- log.info("Using batching for this run." + " Thresholds: num="
- + numSamplesThreshold + ", time=" + timeThreshold);
- }
-
- /**
- * Checks for the Jmeter properties num_sample_threshold and time_threshold,
- * and assigns defaults if not found.
- */
- private void init() {
- this.numSamplesThreshold = JMeterUtils.getPropDefault(
- "num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
- this.timeThreshold = JMeterUtils.getPropDefault("time_threshold",
- DEFAULT_TIME_THRESHOLD);
- }
-
- /**
- * Checks if any sample events are still present in the sampleStore and
- * sends them to the listener. Informs the listener of the testended.
- */
- public void testEnded() {
- try {
- if (sampleStore.size() != 0) {
- sendBatch();
- }
- listener.testEnded();
- } catch (RemoteException err) {
- log.warn("testEnded()", err);
- }
- }
-
- /**
- * Checks if any sample events are still present in the sampleStore and
- * sends them to the listener. Informs the listener of the testended.
- *
- * @param host the hostname that the test has ended on.
- */
- public void testEnded(String host) {
- try {
- if (sampleStore.size() != 0) {
- sendBatch();
- }
- listener.testEnded(host);
- } catch (RemoteException err) {
- log.warn("testEnded(hostname)", err);
- }
- }
-
- /**
- * Stores sample events untill either a time or sample threshold is
- * breached. Both thresholds are reset if one fires. If only one threshold
- * is set it becomes the only value checked against. When a threhold is
- * breached the list of sample events is sent to a listener where the event
- * are fired locally.
- *
- * @param e a Sample Event
- */
- public void SampleOccurred(SampleEvent e) {
- synchronized (sampleStore) {
- // Locate the statistical sample colector
- String key = StatisticalSampleResult.getKey(e);
- StatisticalSampleResult statResult = (StatisticalSampleResult) sampleTable
- .get(key);
- if (statResult == null) {
- statResult = new StatisticalSampleResult(e.getResult());
- // store the new statistical result collector
- sampleTable.put(key, statResult);
- // add a new wrapper samplevent
- sampleStore
- .add(new SampleEvent(statResult, e.getThreadGroup()));
- }
- statResult.add(e.getResult());
- sampleCount++;
- if (numSamplesThreshold != -1) {
- if (sampleCount >= numSamplesThreshold) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Firing sample");
- }
- sendBatch();
- } catch (RemoteException err) {
- log.warn("sampleOccurred", err);
- }
- }
- }
-
- if (timeThreshold != -1) {
- long now = System.currentTimeMillis();
- // Checking for and creating initial timestamp to cheak against
- if (batchSendTime == -1) {
- this.batchSendTime = now + timeThreshold;
- }
-
- if (batchSendTime < now) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Firing time");
- }
- sendBatch();
- this.batchSendTime = now + timeThreshold;
- } catch (RemoteException err) {
- log.warn("sampleOccurred", err);
- }
- }
- }
- }
- }
-
- private void sendBatch() throws RemoteException {
- if (sampleStore.size() > 0) {
- listener.processBatch(sampleStore);
- sampleStore.clear();
- sampleTable.clear();
- sampleCount = 0;
- }
- }
-}
+/*
+ * Copyright 2005 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.samplers;
+
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implements batch reporting for remote testing.
+ *
+ * @author Lars Krog-Jensen
+ * Created: 2005-okt-04
+ */
+public class StatisticalSampleSender implements SampleSender, Serializable {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private static final int DEFAULT_NUM_SAMPLE_THRESHOLD = 100;
+
+ private static final long DEFAULT_TIME_THRESHOLD = 60000L;
+
+ private RemoteSampleListener listener;
+
+ private List sampleStore = new ArrayList();
+
+ private Map sampleTable = new HashMap();
+
+ private int numSamplesThreshold;
+
+ private int sampleCount;
+
+ private long timeThreshold;
+
+ private long batchSendTime = -1;
+
+ public StatisticalSampleSender(){
+ log.warn("Constructor only intended for use in testing");
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param listener that the List of sample events will be sent to.
+ */
+ StatisticalSampleSender(RemoteSampleListener listener) {
+ this.listener = listener;
+ init();
+ log.info("Using batching for this run." + " Thresholds: num="
+ + numSamplesThreshold + ", time=" + timeThreshold);
+ }
+
+ /**
+ * Checks for the Jmeter properties num_sample_threshold and time_threshold,
+ * and assigns defaults if not found.
+ */
+ private void init() {
+ this.numSamplesThreshold = JMeterUtils.getPropDefault(
+ "num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
+ this.timeThreshold = JMeterUtils.getPropDefault("time_threshold",
+ DEFAULT_TIME_THRESHOLD);
+ }
+
+ /**
+ * Checks if any sample events are still present in the sampleStore and
+ * sends them to the listener. Informs the listener of the testended.
+ */
+ public void testEnded() {
+ try {
+ if (sampleStore.size() != 0) {
+ sendBatch();
+ }
+ listener.testEnded();
+ } catch (RemoteException err) {
+ log.warn("testEnded()", err);
+ }
+ }
+
+ /**
+ * Checks if any sample events are still present in the sampleStore and
+ * sends them to the listener. Informs the listener of the testended.
+ *
+ * @param host the hostname that the test has ended on.
+ */
+ public void testEnded(String host) {
+ try {
+ if (sampleStore.size() != 0) {
+ sendBatch();
+ }
+ listener.testEnded(host);
+ } catch (RemoteException err) {
+ log.warn("testEnded(hostname)", err);
+ }
+ }
+
+ /**
+ * Stores sample events untill either a time or sample threshold is
+ * breached. Both thresholds are reset if one fires. If only one threshold
+ * is set it becomes the only value checked against. When a threhold is
+ * breached the list of sample events is sent to a listener where the event
+ * are fired locally.
+ *
+ * @param e a Sample Event
+ */
+ public void SampleOccurred(SampleEvent e) {
+ synchronized (sampleStore) {
+ // Locate the statistical sample colector
+ String key = StatisticalSampleResult.getKey(e);
+ StatisticalSampleResult statResult = (StatisticalSampleResult) sampleTable
+ .get(key);
+ if (statResult == null) {
+ statResult = new StatisticalSampleResult(e.getResult());
+ // store the new statistical result collector
+ sampleTable.put(key, statResult);
+ // add a new wrapper samplevent
+ sampleStore
+ .add(new SampleEvent(statResult, e.getThreadGroup()));
+ }
+ statResult.add(e.getResult());
+ sampleCount++;
+ if (numSamplesThreshold != -1) {
+ if (sampleCount >= numSamplesThreshold) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Firing sample");
+ }
+ sendBatch();
+ } catch (RemoteException err) {
+ log.warn("sampleOccurred", err);
+ }
+ }
+ }
+
+ if (timeThreshold != -1) {
+ long now = System.currentTimeMillis();
+ // Checking for and creating initial timestamp to cheak against
+ if (batchSendTime == -1) {
+ this.batchSendTime = now + timeThreshold;
+ }
+
+ if (batchSendTime < now) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Firing time");
+ }
+ sendBatch();
+ this.batchSendTime = now + timeThreshold;
+ } catch (RemoteException err) {
+ log.warn("sampleOccurred", err);
+ }
+ }
+ }
+ }
+ }
+
+ private void sendBatch() throws RemoteException {
+ if (sampleStore.size() > 0) {
+ listener.processBatch(sampleStore);
+ sampleStore.clear();
+ sampleTable.clear();
+ sampleCount = 0;
+ }
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/testelement/ThreadListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java Sat Nov 26 17:01:05 2005
@@ -1,200 +1,200 @@
-//$Header$
-/*
- * Copyright 2005 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.jorphan.gui;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.swing.event.TableModelListener;
-import javax.swing.event.EventListenerList;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.tree.TreeNode;
-
-import org.apache.jorphan.reflect.Functor;
-
-/**
- * @author Peter Lin
- *
- */
-public abstract class AbstractTreeTableModel extends DefaultTableModel implements TreeTableModel {
-
- protected TreeNode rootNode = null;
- protected EventListenerList listener = new EventListenerList();
-
- protected transient ArrayList objects = new ArrayList();
-
- protected transient List headers = new ArrayList();
-
- protected transient ArrayList classes = new ArrayList();
-
- protected transient ArrayList readFunctors = new ArrayList();
-
- protected transient ArrayList writeFunctors = new ArrayList();
-
- public AbstractTreeTableModel(TreeNode root) {
- this.rootNode = root;
- }
-
- public AbstractTreeTableModel(TreeNode root, boolean editable) {
- this.rootNode = root;
- }
-
- public AbstractTreeTableModel(String[] headers,
- Functor[] readFunctors,
- Functor[] writeFunctors,
- Class[] editorClasses) {
- this.headers.addAll(Arrays.asList(headers));
- this.classes.addAll(Arrays.asList(editorClasses));
- this.readFunctors = new ArrayList(Arrays.asList(readFunctors));
- this.writeFunctors = new ArrayList(Arrays.asList(writeFunctors));
- }
-
- /**
- * The root node for the TreeTable
- * @return
- */
- public Object getRootNode() {
- return this.rootNode;
- }
-
- /* (non-Javadoc)
- * @see org.apache.jorphan.gui.TreeTableModel#getValueAt(java.lang.Object, int)
- */
- public Object getValueAt(Object node, int col) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.jorphan.gui.TreeTableModel#isCellEditable(java.lang.Object, int)
- */
- public boolean isCellEditable(Object node, int col) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.jorphan.gui.TreeTableModel#setValueAt(java.lang.Object, java.lang.Object, int)
- */
- public void setValueAt(Object val, Object node, int column) {
- }
-
- /**
- * The implementation is exactly the same as ObjectTableModel.getColumnCount.
- */
- public int getColumnCount() {
- return headers.size();
- }
-
- /**
- * The implementation is exactly the same as ObjectTableModel.getRowCount.
- */
- public int getRowCount() {
- if (objects == null) {
- return 0;
- }
- return objects.size();
- }
-
- /**
- * By default the abstract class returns true. It is up to subclasses
- * to override the implementation.
- */
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-
- public Class getColumnClass(int arg0) {
- return (Class) classes.get(arg0);
- }
-
- /**
- * Subclasses need to implement the logic for the method and
- * return the value at the specific cell.
- */
- public Object getValueAt(int rowIndex, int columnIndex) {
- return null;
- }
-
- /**
- *
- */
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
-
- }
-
- /**
- *
- */
- public String getColumnName(int columnIndex) {
- return (String) headers.get(columnIndex);
- }
-
- public int getChildCount(Object parent) {
- return 0;
- }
-
- public Object getChild(Object parent, int index) {
- return null;
- }
-
- /**
- * the implementation checks if the Object is a treenode. If it is,
- * it returns isLeaf(), otherwise it returns false.
- * @param node
- * @return
- */
- public boolean isLeaf(Object node) {
- if (node instanceof TreeNode) {
- return ((TreeNode)node).isLeaf();
- } else {
- return false;
- }
- }
-
- /**
- *
- */
- public void addTableModelListener(TableModelListener l) {
- this.listener.add(TableModelListener.class,l);
- }
-
- /**
- *
- */
- public void removeTableModelListener(TableModelListener l) {
- this.listener.remove(TableModelListener.class,l);
- }
-
- public void nodeStructureChanged(TreeNode node) {
-
- }
-
- public void fireTreeNodesChanged(TreeNode source,
- Object[] path,
- int[] indexes,
- Object[] children) {
-
- }
-
- public void clearData() {
- int size = getRowCount();
- objects.clear();
- super.fireTableRowsDeleted(0, size);
- }
-}
+//$Header$
+/*
+ * Copyright 2005 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.jorphan.gui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.swing.event.TableModelListener;
+import javax.swing.event.EventListenerList;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.tree.TreeNode;
+
+import org.apache.jorphan.reflect.Functor;
+
+/**
+ * @author Peter Lin
+ *
+ */
+public abstract class AbstractTreeTableModel extends DefaultTableModel implements TreeTableModel {
+
+ protected TreeNode rootNode = null;
+ protected EventListenerList listener = new EventListenerList();
+
+ protected transient ArrayList objects = new ArrayList();
+
+ protected transient List headers = new ArrayList();
+
+ protected transient ArrayList classes = new ArrayList();
+
+ protected transient ArrayList readFunctors = new ArrayList();
+
+ protected transient ArrayList writeFunctors = new ArrayList();
+
+ public AbstractTreeTableModel(TreeNode root) {
+ this.rootNode = root;
+ }
+
+ public AbstractTreeTableModel(TreeNode root, boolean editable) {
+ this.rootNode = root;
+ }
+
+ public AbstractTreeTableModel(String[] headers,
+ Functor[] readFunctors,
+ Functor[] writeFunctors,
+ Class[] editorClasses) {
+ this.headers.addAll(Arrays.asList(headers));
+ this.classes.addAll(Arrays.asList(editorClasses));
+ this.readFunctors = new ArrayList(Arrays.asList(readFunctors));
+ this.writeFunctors = new ArrayList(Arrays.asList(writeFunctors));
+ }
+
+ /**
+ * The root node for the TreeTable
+ * @return
+ */
+ public Object getRootNode() {
+ return this.rootNode;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jorphan.gui.TreeTableModel#getValueAt(java.lang.Object, int)
+ */
+ public Object getValueAt(Object node, int col) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jorphan.gui.TreeTableModel#isCellEditable(java.lang.Object, int)
+ */
+ public boolean isCellEditable(Object node, int col) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jorphan.gui.TreeTableModel#setValueAt(java.lang.Object, java.lang.Object, int)
+ */
+ public void setValueAt(Object val, Object node, int column) {
+ }
+
+ /**
+ * The implementation is exactly the same as ObjectTableModel.getColumnCount.
+ */
+ public int getColumnCount() {
+ return headers.size();
+ }
+
+ /**
+ * The implementation is exactly the same as ObjectTableModel.getRowCount.
+ */
+ public int getRowCount() {
+ if (objects == null) {
+ return 0;
+ }
+ return objects.size();
+ }
+
+ /**
+ * By default the abstract class returns true. It is up to subclasses
+ * to override the implementation.
+ */
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return true;
+ }
+
+ public Class getColumnClass(int arg0) {
+ return (Class) classes.get(arg0);
+ }
+
+ /**
+ * Subclasses need to implement the logic for the method and
+ * return the value at the specific cell.
+ */
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+
+ }
+
+ /**
+ *
+ */
+ public String getColumnName(int columnIndex) {
+ return (String) headers.get(columnIndex);
+ }
+
+ public int getChildCount(Object parent) {
+ return 0;
+ }
+
+ public Object getChild(Object parent, int index) {
+ return null;
+ }
+
+ /**
+ * the implementation checks if the Object is a treenode. If it is,
+ * it returns isLeaf(), otherwise it returns false.
+ * @param node
+ * @return
+ */
+ public boolean isLeaf(Object node) {
+ if (node instanceof TreeNode) {
+ return ((TreeNode)node).isLeaf();
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ */
+ public void addTableModelListener(TableModelListener l) {
+ this.listener.add(TableModelListener.class,l);
+ }
+
+ /**
+ *
+ */
+ public void removeTableModelListener(TableModelListener l) {
+ this.listener.remove(TableModelListener.class,l);
+ }
+
+ public void nodeStructureChanged(TreeNode node) {
+
+ }
+
+ public void fireTreeNodesChanged(TreeNode source,
+ Object[] path,
+ int[] indexes,
+ Object[] children) {
+
+ }
+
+ public void clearData() {
+ int size = getRowCount();
+ objects.clear();
+ super.fireTableRowsDeleted(0, size);
+ }
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/AbstractTreeTableModel.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java Sat Nov 26 17:01:05 2005
@@ -1,61 +1,61 @@
-/*
- * Copyright 2005 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.jorphan.gui;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
-
-import org.apache.jorphan.reflect.Functor;
-
-/**
- * @author pete
- *
- */
-public class DefaultTreeTableModel extends AbstractTreeTableModel {
-
- public DefaultTreeTableModel() {
- this(new DefaultMutableTreeNode());
- }
-
- /**
- * @param root
- */
- public DefaultTreeTableModel(TreeNode root) {
- super(root);
- }
-
- /**
- * @param root
- * @param editable
- */
- public DefaultTreeTableModel(TreeNode root, boolean editable) {
- super(root, editable);
- }
-
- /**
- * @param headers
- * @param readFunctors
- * @param writeFunctors
- * @param editorClasses
- */
- public DefaultTreeTableModel(String[] headers, Functor[] readFunctors,
- Functor[] writeFunctors, Class[] editorClasses) {
- super(headers, readFunctors, writeFunctors, editorClasses);
- }
-
-}
+/*
+ * Copyright 2005 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.jorphan.gui;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+import org.apache.jorphan.reflect.Functor;
+
+/**
+ * @author pete
+ *
+ */
+public class DefaultTreeTableModel extends AbstractTreeTableModel {
+
+ public DefaultTreeTableModel() {
+ this(new DefaultMutableTreeNode());
+ }
+
+ /**
+ * @param root
+ */
+ public DefaultTreeTableModel(TreeNode root) {
+ super(root);
+ }
+
+ /**
+ * @param root
+ * @param editable
+ */
+ public DefaultTreeTableModel(TreeNode root, boolean editable) {
+ super(root, editable);
+ }
+
+ /**
+ * @param headers
+ * @param readFunctors
+ * @param writeFunctors
+ * @param editorClasses
+ */
+ public DefaultTreeTableModel(String[] headers, Functor[] readFunctors,
+ Functor[] writeFunctors, Class[] editorClasses) {
+ super(headers, readFunctors, writeFunctors, editorClasses);
+ }
+
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/DefaultTreeTableModel.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java?rev=349162&r1=349161&r2=349162&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java Sat Nov 26 17:01:05 2005
@@ -1,69 +1,69 @@
-//$Header$
-/*
- * Copyright 2005 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.jorphan.gui;
-
-import java.util.Vector;
-
-import javax.swing.JTable;
-
-/**
- * @author Peter Lin
- *
- */
-public class JTreeTable extends JTable {
-
- /**
- * The default implementation will use DefaultTreeTableModel
- */
- public JTreeTable() {
- super(new DefaultTreeTableModel());
- }
-
- /**
- * @param numRows
- * @param numColumns
- */
- public JTreeTable(int numRows, int numColumns) {
- super(numRows, numColumns);
- }
-
- /**
- * @param dm
- */
- public JTreeTable(TreeTableModel dm) {
- super(dm);
- }
-
- /**
- * @param rowData
- * @param columnNames
- */
- public JTreeTable(Object[][] rowData, Object[] columnNames) {
- super(rowData, columnNames);
- }
-
- /**
- * @param rowData
- * @param columnNames
- */
- public JTreeTable(Vector rowData, Vector columnNames) {
- super(rowData, columnNames);
- }
-
-}
+//$Header$
+/*
+ * Copyright 2005 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.jorphan.gui;
+
+import java.util.Vector;
+
+import javax.swing.JTable;
+
+/**
+ * @author Peter Lin
+ *
+ */
+public class JTreeTable extends JTable {
+
+ /**
+ * The default implementation will use DefaultTreeTableModel
+ */
+ public JTreeTable() {
+ super(new DefaultTreeTableModel());
+ }
+
+ /**
+ * @param numRows
+ * @param numColumns
+ */
+ public JTreeTable(int numRows, int numColumns) {
+ super(numRows, numColumns);
+ }
+
+ /**
+ * @param dm
+ */
+ public JTreeTable(TreeTableModel dm) {
+ super(dm);
+ }
+
+ /**
+ * @param rowData
+ * @param columnNames
+ */
+ public JTreeTable(Object[][] rowData, Object[] columnNames) {
+ super(rowData, columnNames);
+ }
+
+ /**
+ * @param rowData
+ * @param columnNames
+ */
+ public JTreeTable(Vector rowData, Vector columnNames) {
+ super(rowData, columnNames);
+ }
+
+}
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/src/jorphan/org/apache/jorphan/gui/JTreeTable.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org