1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/******************************************************************************* 2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Copyright (c) 2000, 2009 IBM Corporation and others. 3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * All rights reserved. This program and the accompanying materials 4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * are made available under the terms of the Eclipse Public License v1.0 5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which accompanies this distribution, and is available at 6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * http://www.eclipse.org/legal/epl-v10.html 7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Contributors: 9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * IBM Corporation - initial API and implementation 10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *******************************************************************************/ 11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpackage org.eclipse.test.internal.performance.results.model; 12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Vector; 14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.data.Dim; 16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.*; 17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.views.properties.IPropertyDescriptor; 18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.views.properties.PropertyDescriptor; 19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.views.properties.TextPropertyDescriptor; 20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class DimResultsElement extends ResultsElement { 22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Dim dim; 24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Property descriptors 26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_DIMENSION = "DimResultsElement.dim"; //$NON-NLS-1$ 27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_COUNT = "DimResultsElement.count"; //$NON-NLS-1$ 28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_AVERAGE = "DimResultsElement.average"; //$NON-NLS-1$ 29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_STDDEV = "DimResultsElement.stddev"; //$NON-NLS-1$ 30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_ERROR= "DimResultsElement.error"; //$NON-NLS-1$ 31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_ID_HAD_VALUES = "DimResultsElement.hadvalues"; //$NON-NLS-1$ 32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_DIMENSION = "dimension"; //$NON-NLS-1$ 34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_COUNT= "count"; //$NON-NLS-1$ 35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_AVERAGE = "average"; //$NON-NLS-1$ 36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_STDDEV = "std dev"; //$NON-NLS-1$ 37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_ERROR = "error"; //$NON-NLS-1$ 38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final String P_STR_HAD_VALUES = "had values"; //$NON-NLS-1$ 39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final TextPropertyDescriptor DIMENSION_DESCRIPTOR = new TextPropertyDescriptor(P_ID_DIMENSION, P_STR_DIMENSION); 41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final PropertyDescriptor DIM_COUNT_DESCRIPTOR = new PropertyDescriptor(P_ID_COUNT, P_STR_COUNT); 42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final PropertyDescriptor DIM_AVERAGE_DESCRIPTOR = new PropertyDescriptor(P_ID_AVERAGE, P_STR_AVERAGE); 43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final PropertyDescriptor DIM_STDDEV_DESCRIPTOR = new PropertyDescriptor(P_ID_STDDEV, P_STR_STDDEV); 44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final PropertyDescriptor DIM_ERROR_DESCRIPTOR = new PropertyDescriptor(P_ID_ERROR, P_STR_ERROR); 45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final PropertyDescriptor DIM_HAD_VALUES_DESCRIPTOR = new PropertyDescriptor(P_ID_HAD_VALUES, P_STR_HAD_VALUES); 46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static Vector DESCRIPTORS; 48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static Vector initDescriptors(int status) { 49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS = new Vector(); 50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Status category 51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.add(getInfosDescriptor(status)); 52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.add(getWarningsDescriptor(status)); 53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.add(ERROR_DESCRIPTOR); 54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ERROR_DESCRIPTOR.setCategory("Status"); 55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Results category 56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIMENSION_DESCRIPTOR); 57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIMENSION_DESCRIPTOR.setCategory("Results"); 58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIM_COUNT_DESCRIPTOR); 59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIM_COUNT_DESCRIPTOR.setCategory("Results"); 60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIM_AVERAGE_DESCRIPTOR); 61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIM_AVERAGE_DESCRIPTOR.setCategory("Results"); 62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIM_STDDEV_DESCRIPTOR); 63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIM_STDDEV_DESCRIPTOR.setCategory("Results"); 64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIM_ERROR_DESCRIPTOR); 65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIM_ERROR_DESCRIPTOR.setCategory("Results"); 66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.addElement(DIM_HAD_VALUES_DESCRIPTOR); 67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIM_HAD_VALUES_DESCRIPTOR.setCategory("Results"); 68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Survey category 69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DESCRIPTORS.add(COMMENT_DESCRIPTOR); 70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMMENT_DESCRIPTOR.setCategory("Survey"); 71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DESCRIPTORS; 72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static Vector getDescriptors() { 74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DESCRIPTORS; 75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic DimResultsElement(AbstractResults results, ResultsElement parent, Dim d) { 78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll super(results, parent); 79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.dim = d; 80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollResultsElement createChild(AbstractResults testResults) { 83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return null; 84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate BuildResults getBuildResults() { 87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return (BuildResults) this.results; 88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic String getLabel(Object o) { 91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return this.dim.getName(); 92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* (non-Javadoc) 95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() 96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic IPropertyDescriptor[] getPropertyDescriptors() { 98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Vector descriptors = getDescriptors(); 99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (descriptors == null) { 100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll descriptors = initDescriptors(getStatus()); 101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int size = descriptors.size(); 103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll IPropertyDescriptor[] descriptorsArray = new IPropertyDescriptor[size]; 104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll descriptorsArray[0] = getInfosDescriptor(getStatus()); 105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll descriptorsArray[1] = getWarningsDescriptor(getStatus()); 106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=2; i<size; i++) { 107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll descriptorsArray[i] = (IPropertyDescriptor) descriptors.get(i); 108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return descriptorsArray; 110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* (non-Javadoc) 113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) 114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic Object getPropertyValue(Object propKey) { 116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BuildResults buildResults = getBuildResults(); 117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_DIMENSION)) { 118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return this.dim.getDescription(); 119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_COUNT)) { 121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long count = buildResults.getCount(this.dim.getId()); 122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Double(count); 123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_AVERAGE)) 125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Double(buildResults.getValue(this.dim.getId())); 126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_STDDEV)) 127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Double(buildResults.getDeviation(this.dim.getId())); 128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_ERROR)) 129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Double(buildResults.getError(this.dim.getId())); 130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (propKey.equals(P_ID_HAD_VALUES)) 131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return new Boolean(buildResults.hadValues()); 132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return super.getPropertyValue(propKey); 133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 136