Class DirectoryDialogFactory

java.lang.Object
org.eclipse.tracecompass.tmf.ui.dialog.DirectoryDialogFactory

public final class DirectoryDialogFactory extends Object
A directory dialog factory.

This allows native directory dialogs to be stubbed out for SWTBot tests.

Since:
3.3
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clear the override path so that the next DirectoryDialog opens a normal native dialog.
    static org.eclipse.swt.widgets.DirectoryDialog
    create(org.eclipse.swt.widgets.Shell parent)
    Directory dialog factory, creates a new instance of DirectoryDialog given only its parent.
    static org.eclipse.swt.widgets.DirectoryDialog
    create(org.eclipse.swt.widgets.Shell parent, int style)
    Directory dialog factory, creates a new instance of DirectoryDialog given its parent and a style value describing its behavior and appearance.
    static void
    Set the override path that will be returned by the next DirectoryDialog that is created using this factory when its open() method is called.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 of DirectoryDialog given 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 of DirectoryDialog given its parent and a style value describing its behavior and appearance.

      The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style 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 instance
      style - 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

      public static void setOverridePath(String path)
      Set the override path that will be returned by the next DirectoryDialog that 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 the DirectoryDialog. 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 next DirectoryDialog opens 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.