Class TmfFileDialogFactory

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

public final class TmfFileDialogFactory extends Object
A file dialog factory.

This allows file dialogs to be stubbed out for SWTBot tests.

Since:
2.2
Author:
Matthew Khouzam
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.eclipse.swt.widgets.FileDialog
    create(org.eclipse.swt.widgets.Shell parent)
    File dialog factory, creates a FileDialog.
    static org.eclipse.swt.widgets.FileDialog
    create(org.eclipse.swt.widgets.Shell parent, int style)
    File dialog factory, creates a FileDialog.
    static void
    Set the override string name that will be returned for the next FileDialog.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TmfFileDialogFactory

      public TmfFileDialogFactory()
  • Method Details

    • create

      public static org.eclipse.swt.widgets.FileDialog create(org.eclipse.swt.widgets.Shell parent)
      File dialog factory, creates a FileDialog.

      Constructs a new instance of this class given only its parent.

      If the factory is overridden with setOverrideFiles(String...), the FileDialog will return the set String when open is called instead of opening a system window

      Parameters:
      parent - a shell which will be the parent of the new instance
      Returns:
      the FileDialog
      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.FileDialog create(org.eclipse.swt.widgets.Shell parent, int style)
      File dialog factory, creates a FileDialog.

      Constructs a new instance of this class 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 factory is overridden with setOverrideFiles(String[]), the FileDialog will return the set String when open is called instead of opening a system window

      Parameters:
      parent - a shell which will be the parent of the new instance
      style - the style of dialog to construct
      Returns:
      the FileDialog
      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
      See Also:
      • SWT.SAVE
      • SWT.OPEN
      • SWT.MULTI
    • setOverrideFiles

      public static void setOverrideFiles(String... paths)
      Set the override string name that will be returned for the next FileDialog. Must be called before creating the dialogs. This is a method aimed for testing, This should not be used in product code.
      Parameters:
      paths - the paths to override the FileDialog. They must be absolute. One or many absolute paths may be entered. When many paths are entered, it return an input of a multi-select action if paths is null, it will undo overriding, if paths is a zero length array, it will behave as if the dialog was cancelled.