org.softevo.ample.ui
Class SelectTestsDialog

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by org.softevo.ample.ui.SelectTestsDialog
All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider

public class SelectTestsDialog
extends org.eclipse.jface.dialogs.Dialog

Dialog to choose tests on which Ample is to be executed.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
private  org.eclipse.swt.graphics.Image failingTestIcon
          Icon displayed to the left of the "failing test" label.
private  org.eclipse.swt.widgets.List failingTestsList
          List control that shows the names of the failing tests.
private static int MARGINS
          Margins, in pixels, between the controls and the border of the dialog.
private  org.eclipse.swt.graphics.Image passingTestIcon
          Icon displayed to the left of the "passing tests" label.
private  org.eclipse.swt.widgets.List passingTestsList
          List control that shows the names of the passing tests.
private  org.eclipse.swt.widgets.Button selectAllPassingCheck
          Checkbox used to select all passing tests.
private  org.eclipse.jdt.internal.junit.ui.TestRunInfo selectedFailingTest
          Id of the failing test selected by the user for instrumentation.
private  org.eclipse.jdt.internal.junit.ui.TestRunInfo[] selectedPassingTests
          List of passing runs selected by the user.
private static int SPACING
          Spacing, in pixels, between controls in the dialog.
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
blockedHandler, buttonBar, dialogArea, DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
SelectTestsDialog(org.eclipse.swt.widgets.Shell parentShell, int failingTestIndex)
          Initializes a new instance of SelectTestsDialog.
 
Method Summary
private  void allPassingClicked()
          Updates the dialog when the checkbox for selecting all passing tests is clicked on.
protected  void configureShell(org.eclipse.swt.widgets.Shell newShell)
           
protected  org.eclipse.swt.widgets.Button createButton(org.eclipse.swt.widgets.Composite parent, int id, java.lang.String label, boolean defaultButton)
          Creates a new button with a given ID.
protected  org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
           
private static org.eclipse.swt.widgets.Label createLabelWithIcon(org.eclipse.swt.widgets.Composite dialogArea, org.eclipse.swt.graphics.Image icon)
          Creates a composite control that contains a label with an icon on its left.
private static java.lang.String createTestName(org.eclipse.jdt.internal.junit.ui.TestRunInfo testInfo)
          Creates a single-line description of a test run to be displayed to the user.
private  void fillListWithTests(org.eclipse.swt.widgets.List aTestList, java.util.ArrayList aTestInfos, org.eclipse.jdt.internal.junit.ui.TestRunInfo selectedTest)
          Fills a given list widget with a the names of a specified list of tests.
 org.eclipse.jdt.internal.junit.ui.TestRunInfo getSelectedFailingTest()
          Gets the selected failing test.
 org.eclipse.jdt.internal.junit.ui.TestRunInfo[] getSelectedPassingTests()
          Gets the selected passing tests.
protected  void okPressed()
          Notifies that the OK button of this dialog has been pressed.
private  void updateSelectionPassing()
          Updates the dialog when the user changes the selection of passing tests.
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButtonBar, createButtonsForButtonBar, createContents, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getOKButton, initializeBounds, initializeDialogUnits, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getInitialLocation, getInitialSize, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPACING

private static final int SPACING
Spacing, in pixels, between controls in the dialog.

See Also:
Constant Field Values

MARGINS

private static final int MARGINS
Margins, in pixels, between the controls and the border of the dialog.

See Also:
Constant Field Values

failingTestsList

private org.eclipse.swt.widgets.List failingTestsList
List control that shows the names of the failing tests.

Note that such a control might not be created.


passingTestsList

private org.eclipse.swt.widgets.List passingTestsList
List control that shows the names of the passing tests.

Note that such a control might not be created.


selectAllPassingCheck

private org.eclipse.swt.widgets.Button selectAllPassingCheck
Checkbox used to select all passing tests.

Note that this control is created only when passingTestsList is created.

See Also:
passingTestsList

failingTestIcon

private org.eclipse.swt.graphics.Image failingTestIcon
Icon displayed to the left of the "failing test" label.


passingTestIcon

private org.eclipse.swt.graphics.Image passingTestIcon
Icon displayed to the left of the "passing tests" label.


selectedFailingTest

private org.eclipse.jdt.internal.junit.ui.TestRunInfo selectedFailingTest
Id of the failing test selected by the user for instrumentation.


selectedPassingTests

private org.eclipse.jdt.internal.junit.ui.TestRunInfo[] selectedPassingTests
List of passing runs selected by the user.

Constructor Detail

SelectTestsDialog

public SelectTestsDialog(org.eclipse.swt.widgets.Shell parentShell,
                         int failingTestIndex)
Initializes a new instance of SelectTestsDialog.

Parameters:
parentShell - Owner of this dialog window.
failingTestIndex - Index of failing test initially selected.
Method Detail

getSelectedFailingTest

public org.eclipse.jdt.internal.junit.ui.TestRunInfo getSelectedFailingTest()
Gets the selected failing test.

This method must be called only after the user has pressed the OK button of this dialog.

Returns:
TestRunInfo corresponding to the failing test the user has selected.

getSelectedPassingTests

public org.eclipse.jdt.internal.junit.ui.TestRunInfo[] getSelectedPassingTests()
Gets the selected passing tests.

This method must be called only after the user has pressed the OK button of this dialog.

Returns:
Array of TestRunInfos corresponding to the passing tests the user has selected.

configureShell

protected void configureShell(org.eclipse.swt.widgets.Shell newShell)
Overrides:
configureShell in class org.eclipse.jface.window.Window

createDialogArea

protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
Overrides:
createDialogArea in class org.eclipse.jface.dialogs.Dialog

createButton

protected org.eclipse.swt.widgets.Button createButton(org.eclipse.swt.widgets.Composite parent,
                                                      int id,
                                                      java.lang.String label,
                                                      boolean defaultButton)
Creates a new button with a given ID.

This method overrides Dialog.createButton(org.eclipse.swt.widgets.Composite, int, java.lang.String, boolean) by additionally disabling the OK button if the user must choose passing tests before pressing it.

Overrides:
createButton in class org.eclipse.jface.dialogs.Dialog

okPressed

protected void okPressed()
Notifies that the OK button of this dialog has been pressed.

Overrides:
okPressed in class org.eclipse.jface.dialogs.Dialog

createLabelWithIcon

private static org.eclipse.swt.widgets.Label createLabelWithIcon(org.eclipse.swt.widgets.Composite dialogArea,
                                                                 org.eclipse.swt.graphics.Image icon)
Creates a composite control that contains a label with an icon on its left.

Parameters:
dialogArea - Parent control of the newly creted composite.
icon - Icon to be displayed to the left of the label.
Returns:
Newly created composite's Label.

createTestName

private static java.lang.String createTestName(org.eclipse.jdt.internal.junit.ui.TestRunInfo testInfo)
Creates a single-line description of a test run to be displayed to the user.

Parameters:
testInfo - Test run info that will be shown.
Returns:
String representation of the given test info.

updateSelectionPassing

private void updateSelectionPassing()
Updates the dialog when the user changes the selection of passing tests.

This method makes sure the dialog's OK button is enabled only if enough passing tests are selected by the user.


fillListWithTests

private void fillListWithTests(org.eclipse.swt.widgets.List aTestList,
                               java.util.ArrayList aTestInfos,
                               org.eclipse.jdt.internal.junit.ui.TestRunInfo selectedTest)
Fills a given list widget with a the names of a specified list of tests.

Parameters:
aTestList - List widget to be filled with test names.
aTestInfos - List of tests which names are to be added to the list.
selectedTest - Test that will be initially selected. Set this parameter to null if no test is to be initially selected.

allPassingClicked

private void allPassingClicked()
Updates the dialog when the checkbox for selecting all passing tests is clicked on.

This method selects / deselects all items in the list of the passing tests and updates the "OK" button of the dialog accordingly.