Skip to content

Commit

Permalink
[ui] fixed a defect that caused an org.eclipse.swt.SWTException to be…
Browse files Browse the repository at this point in the history
… raised when running a test (Issue #48)
  • Loading branch information
iteman committed Nov 13, 2013
1 parent 34610bd commit 7c5ef0e
Showing 1 changed file with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2012 KUBO Atsuhiro <kubo@iteman.jp>,
* Copyright (c) 2011-2013 KUBO Atsuhiro <kubo@iteman.jp>,
* All rights reserved.
*
* This file is part of MakeGood.
Expand Down Expand Up @@ -113,10 +113,12 @@ public void mouseUp(MouseEvent e) {
}

public void startTest() {
square.setVisible(false);
canvas.addPaintListener(imageAnimator.getPaintListener());
imageAnimatorThread = new Thread(imageAnimator);
imageAnimatorThread.start();
if (!canvas.isDisposed() && !square.isDisposed()) {
square.setVisible(false);
canvas.addPaintListener(imageAnimator.getPaintListener());
imageAnimatorThread = new Thread(imageAnimator);
imageAnimatorThread.start();
}
}

public void endTest() {
Expand All @@ -127,31 +129,45 @@ public void endTest() {
} catch (InterruptedException e) {
}
}
canvas.removePaintListener(imageAnimator.getPaintListener());
square.setVisible(true);

if (!canvas.isDisposed()) {
canvas.removePaintListener(imageAnimator.getPaintListener());
}

if (!square.isDisposed()) {
square.setVisible(true);
}
}

public void markAsPassed() {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_PASSED).createImage());
square.setToolTipText(Messages.ResultSquare_TestPassed);
if (!square.isDisposed()) {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_PASSED).createImage());
square.setToolTipText(Messages.ResultSquare_TestPassed);
}
}

public void markAsFailed() {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_FAILED).createImage());
square.setToolTipText(Messages.ResultSquare_TestFailed);
if (!square.isDisposed()) {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_FAILED).createImage());
square.setToolTipText(Messages.ResultSquare_TestFailed);
}
}

public void markAsStopped() {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_STOPPED).createImage());
square.setToolTipText(Messages.ResultSquare_TestRunStopped);
if (!square.isDisposed()) {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_STOPPED).createImage());
square.setToolTipText(Messages.ResultSquare_TestRunStopped);
}
}

/**
* @since 2.1.0
*/
public void markAsNoTests() {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_NOTESTS).createImage());
square.setToolTipText(Messages.ResultSquare_NoTests);
if (!square.isDisposed()) {
square.setImage(Activator.getImageDescriptor(IMAGE_PATH_NOTESTS).createImage());
square.setToolTipText(Messages.ResultSquare_NoTests);
}
}

private class ImageAnimator implements Runnable {
Expand Down

0 comments on commit 7c5ef0e

Please sign in to comment.