private void widgetSelectedHelper( ) {
    FileDialogOperation fileDialogOperation;
    String initialFilePath = "";
    FileObject initialFile = null;

    String path = "";
    if ( getText() != null ) {

      try {
        // Attempt to set up initial conditions, if fails browse will fallback to default path.
        initialFilePath = resolveFile( meta, getText() );
        initialFile = KettleVFS.getFileObject( initialFilePath );

        // In cases where filePath is empty set it to the default path returned by kettleVFS.
        if ( Utils.isEmpty( initialFilePath ) && initialFile != null ) {
          initialFilePath = initialFile.getName().getPath();
        }
      } catch ( Exception e ) {
        log.logError( "Error in widgetSelectedHelper", e );
        initialFile = null;
      }

      try {
        fileDialogOperation = constructFileDialogOperation( options.getSelectionOperation(), initialFilePath,
          initialFile, options.getFilters(), options.getProviderFilters(), options.getConnectionFilters() );

        // open dialog
        extensionPointWrapper.callExtensionPoint( log, KettleExtensionPoint.SpoonOpenSaveNew.id, fileDialogOperation );

        // grab path
        path = constructPath( fileDialogOperation );

      } catch ( KettleException ke ) {
        log.logError( "Error in widgetSelectedHelper", ke );
      }
    }

    if ( !Utils.isEmpty( path ) ) {
      setText( path );
    }
  }
@Test
  public void testWidgetSelectedHelper() {
    //SETUP
    LogChannelInterface log = mock( LogChannelInterface.class );
    StringBuilder textVar = new StringBuilder();
    AbstractMeta meta = mock( AbstractMeta.class );
    RepositoryUtility repositoryUtility = mock( RepositoryUtility.class );
    ExtensionPointWrapper extensionPointWrapper = mock( ExtensionPointWrapper.class );
    SelectionAdapterOptions options = new SelectionAdapterOptions( SelectionOperation.FILE );
    SelectionEvent event = mock( SelectionEvent.class );

    String testPath = "/home/devuser/some/path";
    when( meta.environmentSubstitute( testPath ) ).thenReturn( testPath );

    SelectionAdapterFileDialog testInstance1 = createTestInstance( log, textVar, meta, options, repositoryUtility,
      extensionPointWrapper );
    testInstance1.setText( testPath );
    testInstance1.widgetSelected( event );

    assertEquals( testInstance1.getText(), testPath );
  }