Class DirectoryDialogFactory
This allows native directory dialogs to be stubbed out for SWTBot tests.
- Since:
- 3.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear the override path so that the nextDirectoryDialogopens a normal native dialog.static org.eclipse.swt.widgets.DirectoryDialogcreate(org.eclipse.swt.widgets.Shell parent) Directory dialog factory, creates a new instance ofDirectoryDialoggiven only its parent.static org.eclipse.swt.widgets.DirectoryDialogcreate(org.eclipse.swt.widgets.Shell parent, int style) Directory dialog factory, creates a new instance ofDirectoryDialoggiven its parent and a style value describing its behavior and appearance.static voidsetOverridePath(String path) Set the override path that will be returned by the nextDirectoryDialogthat is created using this factory when its open() method is called.
-
Constructor Details
-
DirectoryDialogFactory
public DirectoryDialogFactory()
-
-
Method Details
-
create
public static org.eclipse.swt.widgets.DirectoryDialog create(org.eclipse.swt.widgets.Shell parent) Directory dialog factory, creates a new instance ofDirectoryDialoggiven only its parent.If the override path was previously set with
setOverridePath(String), the DirectoryDialog will return the set String when open() is called instead of opening the native dialog.- Parameters:
parent- a shell which will be the parent of the new instance- Returns:
- the
DirectoryDialog - Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
create
public static org.eclipse.swt.widgets.DirectoryDialog create(org.eclipse.swt.widgets.Shell parent, int style) Directory dialog factory, creates a new instance ofDirectoryDialoggiven its parent and a style value describing its behavior and appearance.The style value is either one of the style constants defined in class
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.If the override path was previously set with
setOverridePath(String), the DirectoryDialog will return the set String when open() is called instead of opening the native dialog.- Parameters:
parent- a shell which will be the parent of the new instancestyle- the style of dialog to construct- Returns:
- the
DirectoryDialog - Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
setOverridePath
Set the override path that will be returned by the nextDirectoryDialogthat is created using this factory when its open() method is called. Must be called before creating the dialog.This is a method aimed for testing, it should not be used in product code.
- Parameters:
path- the path to override theDirectoryDialog. It must be absolute. If the path is null, it will behave as if the dialog was cancelled.
-
clearOverridePath
public static void clearOverridePath()Clear the override path so that the nextDirectoryDialogopens a normal native dialog. Must be called before creating the dialog. It is not necessary to call this method if the override path was consumed by creating a dialog using this factory.This is a method aimed for testing, it should not be used in product code.
-