Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 JBoss Inc 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.drools.guvnor.client.qa;
 
 import  org.drools.guvnor.client.common.PrettyFormLayout;
 import  org.drools.guvnor.client.common.SmallLabel;
 import  org.drools.guvnor.client.packages.PackageBuilderWidget;
 import  org.drools.guvnor.client.rpc.BuilderResult;
 import  org.drools.guvnor.client.rpc.BulkTestRunResult;
 import  org.drools.guvnor.client.rpc.ScenarioResultSummary;
 
 import  com.google.gwt.user.client.Command;
 import  com.google.gwt.user.client.ui.Button;
 import  com.google.gwt.user.client.ui.ClickListener;
 import  com.google.gwt.user.client.ui.Composite;
 import  com.google.gwt.user.client.ui.FlexTable;
 import  com.google.gwt.user.client.ui.HTML;
 import  com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import  com.google.gwt.user.client.ui.HorizontalPanel;
 import  com.google.gwt.user.client.ui.ListBox;
 import  com.google.gwt.user.client.ui.Panel;
 import  com.google.gwt.user.client.ui.SimplePanel;
 import  com.google.gwt.user.client.ui.Widget;
 import  com.google.gwt.core.client.GWT;
 import  com.gwtext.client.util.Format;

This presents the results of a bulk run.

Author(s):
Michael Neale
 
 public class BulkRunResultWidget extends Composite {
 
 	private BulkTestRunResult result;
 	private PrettyFormLayout layout;
 	private SimplePanel parent;
 	private Command close;
     private Constants constants = GWT.create(Constants.class);
 
 
     public BulkRunResultWidget(BulkTestRunResult resultEditItemEvent editEvent, Command close) {
 
 		this. = close;
 		this. = result;
 		this. = editEvent;
 		 = new SimplePanel();
 
 		if (result.result != null && result.result.lines != null && result.result.lines.length > 0) {
 		} else {
 		}
 
 
 		initWidget();
 	}
 
 
 	private void showResult() {
 
 		clear();
 
 		int grandTotal = 0;
 		int totalFailures = 0;
 		FlexTable summaryTable = new FlexTable();
 		ScenarioResultSummary[] summaries = .;
 		for (int i = 0; i < summaries.length; i++) {
 			final ScenarioResultSummary s = summaries[i];
 			grandTotal = grandTotal + s.total;
 			totalFailures = totalFailures + s.failures;
 
 			//now render this summary
 			summaryTable.setWidget(i, 0, new SmallLabel(s.scenarioName + ":"));
 			summaryTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
 
 			if (s.failures > 0) {
 				summaryTable.setWidget(i, 1, ScenarioWidget.getBar("#CC0000", 150, s.total - s.failures, s.total)); //NON-NLS
 			} else {
 				summaryTable.setWidget(i, 1, ScenarioWidget.getBar("GREEN", 150, 100));  //NON-NLS
 			}
 
             
			summaryTable.setWidget(i, 2, new SmallLabel(Format.format(.TestFailureBulkFailures(), s.failures, s.total)));
			Button open = new Button(.Open());
			open.addClickListener(new ClickListener() {
				public void onClick(Widget w) {
					.open(s.uuid);
				}
			});
			summaryTable.setWidget(i, 3, open);
		}
		//add the summary to the layout
		summaryTable.setWidth("100%");
		HorizontalPanel resultsH = new HorizontalPanel();
		if (totalFailures > 0) {
			resultsH.add(ScenarioWidget.getBar("#CC0000", 300, totalFailuresgrandTotal)); //NON-NLS
else {
			resultsH.add(ScenarioWidget.getBar("GREEN", 300, 100)); //NON-NLS
		}
		resultsH.add(new SmallLabel("&nbsp;" + Format.format(.failuresOutOFExpectations(),totalFailuresgrandTotal)));
		.startSection();
		.addAttribute(.OverallResult(), new HTML((totalFailures==0) ? .SuccessOverall() : .FailureOverall()));
		.addAttribute(.Results(), resultsH);
		HorizontalPanel coveredH = new HorizontalPanel();
		if (. < 100) {
			coveredH.add(ScenarioWidget.getBar("YELLOW", 300, .));  //NON-NLS
else {
			coveredH.add(ScenarioWidget.getBar("GREEN", 300, 100)); //NON-NLS
		}
		coveredH.add(new SmallLabel("&nbsp;" + Format.format(.RuleCoveragePercent(), .)));
		.addAttribute(.RulesCovered(), coveredH);
		if (. < 100) {
				ListBox uncoveredRules = new ListBox();
				for (int i = 0; i < ..i++) {
					uncoveredRules.addItem(.[i]);
				}
				uncoveredRules.setMultipleSelect(true);
					uncoveredRules.setVisibleItemCount(20);
else {
					uncoveredRules.setVisibleItemCount(..);
				}
				.addAttribute(.UncoveredRules(), uncoveredRules);
		}
		.endSection();
		.startSection(.Scenarios());
		.addAttribute(""summaryTable);
		Button c = new Button(.Close());
		c.addClickListener(new ClickListener() {
			public void onClick(Widget w) {
				.execute();
			}
		});
		.addRow(c);
		.endSection();
	}
	private void clear() {
		.clear();
		 = new PrettyFormLayout();
	}
	private void showErrors() {
		BuilderResult errors = .;
		Panel err = new SimplePanel();
		PackageBuilderWidget.showBuilderErrors(errorserr);
		.addRow(err);
		.endSection();
	}
New to GrepCode? Check out our FAQ X