Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Added a PieChartIconRenderer

* Fixed autorun issue
* Updated DSView reporting method access to model
* ImageHelper methods to generate images for DS reports
  • Loading branch information...
commit 44fc3b493d79ea94be34f573dfcd18873f1e7604 1 parent ed7c0c6
@olas authored
View
2  plugins/net.bioclipse.ds.ui/META-INF/MANIFEST.MF
@@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy
Export-Package: net.bioclipse.ds.ui,
net.bioclipse.ds.ui.actions,
- net.bioclipse.ds.ui.report,
+ net.bioclipse.ds.ui.utils,
net.bioclipse.ds.ui.views
Import-Package: javax.vecmath,
org.apache.log4j
View
33 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/GeneratorHelper.java
@@ -0,0 +1,33 @@
+package net.bioclipse.ds.ui;
+
+import java.util.List;
+
+import net.bioclipse.cdk.jchempaint.editor.JChemPaintEditor;
+import net.bioclipse.cdk.jchempaint.view.ChoiceGenerator;
+
+import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.renderer.RendererModel;
+import org.openscience.cdk.renderer.generators.IGenerator;
+import org.openscience.cdk.renderer.generators.IGeneratorParameter;
+
+public class GeneratorHelper {
+
+ public static void turnOffAllExternalGenerators(JChemPaintEditor jcp) {
+ //Switch off all other DS-generators!
+ List<IGenerator<IAtomContainer>> generators = ChoiceGenerator.getGeneratorsFromExtension();
+
+ RendererModel model = jcp.getWidget().getRenderer2DModel();
+
+ for(IGenerator generator: generators) {
+ List<IGeneratorParameter<?>> params = generator.getParameters();
+ if(params.isEmpty()) continue;
+ for (IGeneratorParameter param : params){
+ if (param.getDefault() instanceof Boolean) {
+ IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
+ model.set(bp.getClass(), false);
+ }
+ }
+ }
+ }
+
+}
View
153 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/ImageHelper.java
@@ -1,44 +1,61 @@
-package net.bioclipse.ds.ui;
+/* *****************************************************************************
+ * Copyright (c) 2009-2010 Ola Spjuth.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ola Spjuth - initial API and implementation
+ ******************************************************************************/package net.bioclipse.ds.ui;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
+
import java.util.ArrayList;
import java.util.List;
-
-import javax.imageio.ImageIO;
+import java.util.Map;
import net.bioclipse.cdk.business.ICDKManager;
import net.bioclipse.cdk.domain.ICDKMolecule;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.ds.model.ITestResult;
+import net.bioclipse.ds.model.result.AtomResultMatch;
import net.bioclipse.ds.model.result.BlueRedColorScaleGenerator;
+import net.bioclipse.ds.model.result.ExternalMoleculeMatch;
import net.bioclipse.ds.model.result.PosNegIncColorGenerator;
import net.bioclipse.ds.model.result.SubStructureMatch;
+import org.apache.log4j.Logger;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.layout.StructureDiagramGenerator;
import org.openscience.cdk.renderer.AtomContainerRenderer;
+import org.openscience.cdk.renderer.RendererModel;
import org.openscience.cdk.renderer.font.AWTFontManager;
import org.openscience.cdk.renderer.generators.BasicAtomGenerator;
import org.openscience.cdk.renderer.generators.BasicBondGenerator;
import org.openscience.cdk.renderer.generators.BasicSceneGenerator;
import org.openscience.cdk.renderer.generators.HighlightAtomGenerator;
import org.openscience.cdk.renderer.generators.IGenerator;
+import org.openscience.cdk.renderer.generators.IGeneratorParameter;
import org.openscience.cdk.renderer.generators.HighlightAtomGenerator.HighlightAtomDistance;
import org.openscience.cdk.renderer.visitor.AWTDrawVisitor;
-
+/**
+ * Helper classes to generate Images of structures with DS-highlighting
+ * @author ola
+ *
+ */
public class ImageHelper {
- public static byte[] createImage( net.bioclipse.core.domain.IMolecule bcmol,
+ private static final Logger logger = Logger.getLogger(ImageHelper.class);
+
+ public static Image createImage( net.bioclipse.core.domain.IMolecule bcmol,
ITestResult match )
throws BioclipseException {
@@ -50,16 +67,28 @@
}
- public static byte[] createImage( net.bioclipse.core.domain.IMolecule bcmol,
+ @SuppressWarnings("unchecked")
+ public static Image createImage( net.bioclipse.core.domain.IMolecule bcmol,
ITestResult match, int WIDTH, int HEIGHT, double zoom)
throws BioclipseException {
if (bcmol==null)
return null;
-
+
ICDKManager cdk = net.bioclipse.cdk.business.Activator
- .getDefault().getJavaCDKManager();
- ICDKMolecule cdkmol= cdk.asCDKMolecule( bcmol );
+ .getDefault().getJavaCDKManager();
+
+ ICDKMolecule cdkmol=null;
+
+ //Render external match
+ if (match instanceof ExternalMoleculeMatch) {
+ ExternalMoleculeMatch extmatch = (ExternalMoleculeMatch) match;
+ cdkmol=extmatch.getMatchedMolecule();
+ }else{
+ //Or the query molecule
+ cdkmol=cdk.asCDKMolecule( bcmol );
+ }
+
// the draw area and the image should be the same size
Rectangle drawArea = new Rectangle(WIDTH, HEIGHT);
@@ -80,44 +109,78 @@
//Add the standard generators
generators.add(new BasicSceneGenerator());
- generators.add(new HighlightAtomGenerator());
+// generators.add(new HighlightAtomGenerator());
generators.add(new BasicBondGenerator());
- SubStructureMatch newMatch=null;
- //If we have a match:
- //We need to generate a new ISubstructureMatch from pre-clone and SDG
-// if ( match instanceof SubStructureMatch ) {
-// SubStructureMatch submatch = (SubStructureMatch) match;
-//
-// newMatch=new SubStructureMatch(submatch.getName(),
-// submatch.getClassification());
-// newMatch.setTestRun( ((SubStructureMatch) match).getTestRun() );
-// IAtomContainer newac = NoNotificationChemObjectBuilder.getInstance().newAtomContainer();
-// for (IAtom atom : match.getAtomContainer().atoms()){
-// int atomno=cdkmol.getAtomContainer().getAtomNumber( atom );
-// IAtom newAtom=mol.getAtom( atomno );
-// newac.addAtom( newAtom );
-// }
-//
-// newMatch.setAtomContainer( newac );
-// }
-
- if (newMatch!=null){
- BlueRedColorScaleGenerator generator=new BlueRedColorScaleGenerator();
- PosNegIncColorGenerator gen2=new PosNegIncColorGenerator();
- generators.add(generator);
- generators.add( gen2 );
- }
-
- generators.add(new BasicAtomGenerator());
+ //Add all generators, we turn them on/off by a parameter now
+ BlueRedColorScaleGenerator generator=new BlueRedColorScaleGenerator();
+ PosNegIncColorGenerator gen2=new PosNegIncColorGenerator();
+ generators.add(generator);
+ generators.add( gen2 );
+ BasicAtomGenerator agen = new BasicAtomGenerator();
+ generators.add(agen);
+
// the renderer needs to have a toolkit-specific font manager
AtomContainerRenderer renderer = new AtomContainerRenderer(generators, new AWTFontManager());
- // the call to 'setup' only needs to be done on the first paint
renderer.setup(mol, drawArea);
- renderer.getRenderer2DModel().set(HighlightAtomDistance.class, 18.0 );
+ RendererModel model = renderer.getRenderer2DModel();
+// model.set(HighlightAtomDistance.class, 18.0 );
+
+ model.set(BasicAtomGenerator.CompactAtom.class, true);
+
+ //Turn off all external generators
+ for(IGenerator gen : generators) {
+ List<IGeneratorParameter<?>> params = gen.getParameters();
+ if(params.isEmpty()) continue;
+ for (IGeneratorParameter param : params){
+ if (param.getDefault() instanceof Boolean) {
+ IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
+ model.set(bp.getClass(), false);
+ }
+ }
+ }
+
+ //Now, turn on the generator for this match
+ //IF match, turn on the supplied generator
+ if ( match != null ) {
+
+ Class<? extends IGeneratorParameter<Boolean>> visibilityParam = match.getGeneratorVisibility();
+ Class<? extends IGeneratorParameter<Map<Integer, Integer>>> atomMapParam = match.getGeneratorAtomMap();
+
+ if (visibilityParam==null){
+ logger.debug("The selected TestResult does not provide a " +
+ "generatorVisibility. No generator turned on.");
+// return null;
+ }
+ else{
+
+
+ //And turn only the selected on
+ model.set(visibilityParam, true);
+ logger.debug("Turned on visibility for " +
+ "Generator: " + match.getGeneratorVisibility());
+
+ if (atomMapParam!=null){
+ if (match instanceof AtomResultMatch) {
+ AtomResultMatch atomResMatch = (AtomResultMatch) match;
+ model.set(atomMapParam, atomResMatch.getResultMap());
+ logger.debug(" ...and AtomMapGeneratorParameter is used with content.");
+ }else{
+ logger.debug(" ...however, an AtomMapGeneratorParameter is available but TestResult is not PosNegIncMatch.");
+ }
+
+ }
+ else{
+ logger.debug(" ...however, no AtomMapGeneratorParameter is available.");
+ }
+ }
+
+ }
+
+
//TODO: belows does not seem to work properly
// renderer.setZoomToFit( WIDTH, HEIGHT, WIDTH, HEIGHT );
@@ -130,7 +193,12 @@
// the paint method also needs a toolkit-specific renderer
renderer.paint(mol, new AWTDrawVisitor(g2));
+
+ return image;
+ /*
+ * We don't serialize to byte[] anymore
+ *
ByteArrayOutputStream bo=new ByteArrayOutputStream();
try {
@@ -145,6 +213,7 @@
}
return null;
+ */
}
}
View
128 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/utils/PieChartProducer.java
@@ -0,0 +1,128 @@
+package net.bioclipse.ds.ui.utils;
+
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * GC example snippet: create an icon (in memory)
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class PieChartProducer {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+
+ int greens=3;
+ int reds=2;
+ int blue=1;
+ int radius=44;
+
+ Image icon=generatePieChart(display, greens, reds, blue, radius, 50);
+
+ Shell shell = new Shell (display);
+ Button button = new Button (shell, SWT.PUSH);
+ button.setImage (icon);
+ button.setSize (100, 100);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ icon.dispose ();
+ display.dispose ();
+ }
+
+ public static Image generatePieChart(Display display, int greens, int reds, int blues, int radius, int imagesize) {
+ Color red = display.getSystemColor (SWT.COLOR_RED);
+ Color green = display.getSystemColor (SWT.COLOR_GREEN);
+ Color blue = display.getSystemColor (SWT.COLOR_BLUE);
+ Color black = display.getSystemColor (SWT.COLOR_BLACK);
+ Color white = display.getSystemColor (SWT.COLOR_WHITE);
+ Color gray = new Color(display, 150,150,150);
+
+ Color lineColor=gray;
+
+ Image image = new Image (display, imagesize, imagesize);
+ GC gc = new GC (image);
+
+ int totals=greens + reds + blues;
+ int greenDeg=(int)(360*((float)greens/(totals)));;
+// System.out.println("Green deg: " + greenDeg);
+
+ int redDeg=(int)(360*((float)reds/(totals)));
+// System.out.println("Red deg: " + redDeg);
+
+ int blueDeg=(int)(360*((float)blues/(totals)));
+// System.out.println("Blue deg: " + blueDeg);
+
+ int currentDeg=90; //12 o'clock
+ if (blues>0){
+ gc.setBackground (blue);
+ gc.fillArc(0,0, radius, radius, currentDeg, blueDeg);
+ currentDeg+=blueDeg;
+ gc.setBackground (lineColor);
+ gc.setForeground(lineColor);
+ gc.fillArc(0,0, radius, radius, currentDeg, 1);
+ }
+ if (reds>0){
+ gc.setBackground (red);
+ gc.fillArc(0,0, radius, radius, currentDeg, redDeg);
+ currentDeg+=redDeg;
+ gc.setBackground (lineColor);
+ gc.setForeground(lineColor);
+ gc.fillArc(0,0, radius, radius, currentDeg, 1);
+ }
+ if (greens>0){
+ gc.setBackground (green);
+ gc.fillArc(0,0, radius, radius, currentDeg, greenDeg);
+ currentDeg+=greenDeg;
+ gc.setBackground (lineColor);
+ gc.setForeground(lineColor);
+ gc.fillArc(0,0, radius, radius, currentDeg, 1);
+ }
+
+ gc.setBackground (lineColor);
+ gc.setForeground(lineColor);
+ gc.drawOval(0, 0, radius, radius);
+
+
+ gc.dispose ();
+
+ return image;
+
+// ImageData imageData = image.getImageData ();
+//
+// PaletteData palette = new PaletteData (
+// new RGB [] {
+// new RGB (0, 0, 0),
+// new RGB (0xFF, 0xFF, 0xFF),
+// });
+// ImageData maskData = new ImageData (20, 20, 1, palette);
+// Image mask = new Image (display, maskData);
+// gc = new GC (mask);
+// gc.setBackground (black);
+// gc.fillRectangle (0, 0, 20, 20);
+// gc.setBackground (white);
+// gc.fillOval(5,5,10,10);
+// gc.dispose ();
+// maskData = mask.getImageData ();
+//
+//// Image icon = new Image (display, imageData, maskData);
+// Image icon = new Image (display, imageData);
+// return icon;
+ }
+}
View
107 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/views/DSView.java
@@ -24,24 +24,17 @@
import net.bioclipse.cdk.ui.sdfeditor.editor.MultiPageMoleculesEditorPart;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.util.LogUtils;
-import net.bioclipse.ds.report.AbstractTestReportModel;
import net.bioclipse.ds.ui.Activator;
import net.bioclipse.ds.business.IDSManager;
-import net.bioclipse.ds.model.DSException;
import net.bioclipse.ds.model.Endpoint;
import net.bioclipse.ds.model.IDSTest;
import net.bioclipse.ds.model.ITestResult;
import net.bioclipse.ds.model.TestRun;
import net.bioclipse.ds.model.result.AtomResultMatch;
-import net.bioclipse.ds.model.result.BlueRedColorScaleGenerator;
-import net.bioclipse.ds.model.result.PosNegIncColorGenerator;
-import net.bioclipse.ds.model.result.PosNegIncMatch;
import net.bioclipse.ds.model.result.SimpleResult;
-import net.bioclipse.ds.model.result.SubStructureMatch;
import net.bioclipse.ds.report.DSSingleReportModel;
-import net.bioclipse.ds.report.StatusHelper;
import net.bioclipse.ds.ui.DSContextProvider;
-import net.bioclipse.ds.ui.ImageHelper;
+import net.bioclipse.ds.ui.GeneratorHelper;
import net.bioclipse.ds.ui.VotingConsensus;
import net.bioclipse.jobs.BioclipseJob;
import net.bioclipse.jobs.BioclipseJobUpdateHook;
@@ -75,7 +68,6 @@
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
-import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.renderer.RendererModel;
import org.openscience.cdk.renderer.generators.IGenerator;
@@ -214,7 +206,15 @@ public void createPartControl(Composite parent) {
public void selectionChanged( SelectionChangedEvent event ) {
updateActionStates();
- turnOffAllExternalGenerators();
+
+ JChemPaintEditor jcp=getJCPfromActiveEditor();
+ if (jcp==null) return;
+
+ //Turn off all ext generators who has a boolean parameter
+ //Not the best, but nothing else to do currently
+ //TODO: Improve on this!
+ GeneratorHelper.turnOffAllExternalGenerators(jcp);
+
Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();
if ( obj instanceof ITestResult ) {
ITestResult tr = (ITestResult) obj;
@@ -227,8 +227,6 @@ public void selectionChanged( SelectionChangedEvent event ) {
return;
}
- JChemPaintEditor jcp=getJCPfromActiveEditor();
- if (jcp==null) return;
RendererModel model = jcp.getWidget().getRenderer2DModel();
@@ -254,29 +252,9 @@ public void selectionChanged( SelectionChangedEvent event ) {
}
}
- private void turnOffAllExternalGenerators() {
- //Switch off all other DS-generators!
- List<IGenerator<IAtomContainer>> generators = ChoiceGenerator.getGeneratorsFromExtension();
-
- JChemPaintEditor jcp=getJCPfromActiveEditor();
- if (jcp==null) return;
-
- RendererModel model = jcp.getWidget().getRenderer2DModel();
-
- for(IGenerator generator: generators) {
- List<IGeneratorParameter<?>> params = generator.getParameters();
- if(params.isEmpty()) continue;
- for (IGeneratorParameter param : params){
- if (param.getDefault() instanceof Boolean) {
- IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
- model.set(bp.getClass(), false);
- }
- }
- }
- }
-
});
+
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
viewer.getTree().setLayoutData(gridData);
@@ -925,7 +903,7 @@ public void run() {
else
tr.setStatus( TestRun.FINISHED );
- viewer.refresh( tr );
+ viewer.refresh( );
viewer.setExpandedState( tr, true );
updateConsensusView();
@@ -1072,9 +1050,6 @@ public DSSingleReportModel waitAndReturnReportModel(){
return null;
}
- //Set up and return ReportModel
- DSSingleReportModel reportmodel=new DSSingleReportModel();
-
//Get mol from first testrun
TestRun first = activeTestRuns.get( 0 );
ICDKMolecule mol = first.getMolecule();
@@ -1084,49 +1059,17 @@ public DSSingleReportModel waitAndReturnReportModel(){
return null;
}
- //Get name
- String name = (String) mol.getAtomContainer().getProperty( CDKConstants.TITLE );
- if (name==null)
- name="N/A";
- reportmodel.setCompoundName( name );
-
- ICDKManager cdk = net.bioclipse.cdk.business.Activator
- .getDefault().getJavaCDKManager();
- try {
- //Generate SMILES
- String smi=cdk.calculateSMILES( mol );
- reportmodel.setSMILES( smi );
-
- //Generate Mass
- double mw=cdk.calculateMass( mol );
- reportmodel.setMw( mw );
-
- //Generate structure image
- byte[] structureImage = ImageHelper.createImage(
- mol, null, 200,200,0.5);
- reportmodel.setQueryStructure( structureImage );
- int cons=VotingConsensus.getConsensusFromTestRuns(activeTestRuns);
- reportmodel.setConsensusText( StatusHelper.statusToString( cons ) );
- reportmodel.setConsensusImage( StatusHelper.statusToImageData(cons ) );
- } catch ( BioclipseException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- //Add all testmodels to ReportModel
- for (TestRun tr : activeTestRuns){
- AbstractTestReportModel testreportmodel =
- tr.getTest().getReportmodel();
- if (testreportmodel!=null){
- testreportmodel.setName( tr.getTest().getId() );
- if (testreportmodel!=null){
- testreportmodel.setTestrun( tr );
- reportmodel.addTestModel( testreportmodel );
- }
- }
- }
-
+ IDSManager ds =net.bioclipse.ds.Activator.getDefault().getJavaManager();
+ //Set up and return ReportModel
+ DSSingleReportModel reportmodel=null;
+ try {
+ reportmodel = new DSSingleReportModel(mol, ds.getFullEndpoints());
+ } catch (BioclipseException e) {
+ e.printStackTrace();
+ }
+
return reportmodel;
+
}
@@ -1548,6 +1491,8 @@ public void pageChanged(PageChangedEvent event) {
updateView();
}else{
doClearAndSetUpNewTestRuns(mol);
+ if (autorun)
+ runAction.run();
}
}
@@ -1617,6 +1562,8 @@ private void JCPModelLoaded(ICDKMolecule cdkmol){
logger.debug ("EventView reacting: JCP model is loaded. Molecule: " + cdkmol);
doSetUpTestRuns(cdkmol);
//TODO: VERIFY
+ if (autorun && !executed)
+ runAction.run();
}
private void JCPModelChanged(ICDKMolecule cdkmol){
@@ -1624,6 +1571,8 @@ private void JCPModelChanged(ICDKMolecule cdkmol){
("EventView reacting: JCP editor model has changed");
doClearAndSetUpNewTestRuns(cdkmol);
//TODO: VERIFY
+ if (autorun && !executed)
+ runAction.run();
}
View
56 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/views/DSViewLabelProvider.java
@@ -1,5 +1,5 @@
/* *****************************************************************************
- * Copyright (c) 2009 Ola Spjuth.
+ * Copyright (c) 2009-2010 Ola Spjuth.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,23 +10,21 @@
******************************************************************************/
package net.bioclipse.ds.ui.views;
-import net.bioclipse.ds.Activator;
+
import net.bioclipse.ds.model.Endpoint;
import net.bioclipse.ds.model.IDSTest;
import net.bioclipse.ds.model.ITestResult;
import net.bioclipse.ds.model.TestRun;
+import net.bioclipse.ds.ui.utils.PieChartProducer;
-import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
/**
*
@@ -39,6 +37,29 @@ public Image getImage( Object element ) {
if ( element instanceof Endpoint ) {
Endpoint ep = (Endpoint)element;
+
+ if (ep.getTestruns()!=null){
+ int pos=0;
+ int neg=0;
+ int inc=0;
+ for (TestRun run : ep.getTestruns()){
+ if (run.getMatches()==null || run.getMatches().size()<=0)
+ continue;
+ if (run.getConsensusStatus()==ITestResult.POSITIVE)
+ pos++;
+ else if (run.getConsensusStatus()==ITestResult.NEGATIVE)
+ neg++;
+ else if (run.getConsensusStatus()==ITestResult.INCONCLUSIVE)
+ inc++;
+ }
+ if ( neg!=0 || pos!=0 || inc!=0){
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ Image img = PieChartProducer.generatePieChart(display,
+ neg, pos, inc, 12, 16);
+ return img;
+ }
+ }
+
return ep.getIcon();
}
else if ( element instanceof ITestResult ) {
@@ -51,6 +72,29 @@ else if ( element instanceof IDSTest ) {
}
else if ( element instanceof TestRun ) {
TestRun run = (TestRun) element;
+
+ if (run.getMatches()!=null){
+ int pos=0;
+ int neg=0;
+ int inc=0;
+ for (ITestResult res : run.getMatches()){
+ if (run.getMatches()==null || run.getMatches().size()<=0)
+ continue;
+ if (res.getClassification()==ITestResult.POSITIVE)
+ pos++;
+ else if (res.getClassification()==ITestResult.NEGATIVE)
+ neg++;
+ else if (res.getClassification()==ITestResult.INCONCLUSIVE)
+ inc++;
+ }
+ if ( neg!=0 || pos!=0 || inc!=0){
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ Image img = PieChartProducer.generatePieChart(display,
+ neg, pos, inc, 12, 16);
+ return img;
+ }
+ }
+
return run.getIcon();
}
Please sign in to comment.
Something went wrong with that request. Please try again.