[458070] Lack of WorkspaceTask causes performer to assume a workspace at the current working directory

https://bugs.eclipse.org/bugs/show_bug.cgi?id=458070
diff --git a/plugins/org.eclipse.oomph.extractor/src/extractor.c b/plugins/org.eclipse.oomph.extractor/src/extractor.c
index 88933d8..50ea624 100644
--- a/plugins/org.eclipse.oomph.extractor/src/extractor.c
+++ b/plugins/org.eclipse.oomph.extractor/src/extractor.c
@@ -43,26 +43,146 @@
  * User Interface
  ***************************************************************************************/
 
+static BOOL CALLBACK
+enumChildWindowsCallback (HWND hWnd, LPARAM lParam)
+{
+  _TCHAR className[MAX_PATH];
+  className[0] = 0;
+
+  GetClassName (hWnd, className, sizeof(className));
+  className[MAX_PATH - 1] = 0;
+
+  if (lstrcmpi (className, _T("SysTreeView32")) == 0)
+  {
+    HWND* phWnd = (HWND*) lParam;
+    if (phWnd)
+    {
+      *phWnd = hWnd;
+    }
+
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
 static int CALLBACK
 browseCallback (HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
 {
-  if (uMsg == BFFM_INITIALIZED)
+  static BOOL ensureVisible = FALSE;
+
+  switch (uMsg)
   {
-    HINSTANCE hInstance = GetModuleHandle (NULL);
-    HICON hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(ID_ICON));
-    SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIcon);
+    case BFFM_INITIALIZED:
+      {
+        HINSTANCE hInstance = GetModuleHandle (NULL);
+        HICON hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(ID_ICON));
+        SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIcon);
+
+        ensureVisible = FALSE;
+
+        _TCHAR buffer[MAX_PATH];
+        buffer[0] = 0;
+
+        GetCurrentDirectory (MAX_PATH, buffer);
+        buffer[MAX_PATH - 1] = 0;
+//        strcat (buffer, _T("\\EclipseInstaller"));
+
+        OSVERSIONINFO versionInfo;
+        versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+
+        if (GetVersionEx (&versionInfo) && versionInfo.dwMajorVersion >= 6 && versionInfo.dwMinorVersion >= 1)
+        {
+          ensureVisible = TRUE;
+        }
+
+        SendMessage (hWnd, BFFM_SETSELECTION, TRUE, (LPARAM) buffer);
+        break;
+      }
+
+    case BFFM_SELCHANGED:
+      {
+        if (ensureVisible)
+        {
+          ensureVisible = FALSE;
+
+          HWND hWndTree = NULL;
+          EnumChildWindows (hWnd, enumChildWindowsCallback, (LPARAM) &hWndTree);
+
+          if (hWndTree)
+          {
+            HTREEITEM hTreeItem = TreeView_GetSelection(hWndTree);
+            if (hTreeItem)
+            {
+              TreeView_EnsureVisible(hWndTree, hTreeItem);
+            }
+          }
+        }
+
+        break;
+      }
   }
 
   return 0;
 }
 
+static BOOL CALLBACK
+dialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+  switch (msg)
+  {
+    case WM_INITDIALOG:
+      {
+        HINSTANCE hInstance = GetModuleHandle (NULL);
+        HICON hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(ID_ICON));
+        SendMessage (hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon);
+        return TRUE;
+      }
+
+    case WM_CLOSE:
+      EndDialog (hDlg, 0);
+      return TRUE;
+
+    case WM_COMMAND:
+      switch (LOWORD(wParam))
+      {
+        case IDOK:
+          EndDialog (hDlg, 0);
+          return TRUE;
+
+        case IDC_EDIT1:
+          switch (HIWORD(wParam))
+          {
+            case EN_CHANGE:
+              {
+                HWND hText = (HWND) lParam;
+                _TCHAR buffer[MAX_PATH];
+                GetWindowText (hText, buffer, sizeof(buffer));
+
+                printf (_T("%s\n"), buffer);
+                fflush (stdout);
+                return TRUE;
+              }
+          }
+
+          return TRUE;
+      }
+
+      break;
+  }
+
+  return FALSE;
+}
+
 static _TCHAR*
 browseForFolder (HWND hwndOwner, LPCTSTR lpszTitle)
 {
   CoInitialize (NULL);
 
+  DialogBox(NULL, MAKEINTRESOURCE(ID_DLGBOX2), hwndOwner, (DLGPROC)dialogProc);
+
   _TCHAR* result = NULL;
-  TCHAR buffer[MAX_PATH];
+  _TCHAR buffer[MAX_PATH];
 
   BROWSEINFO browseInfo = { 0 };
   browseInfo.hwndOwner = hwndOwner;
@@ -83,7 +203,7 @@
     CoTaskMemFree (itemIDList);
   }
 
-  // CoUninitialize ();
+// CoUninitialize ();
   return result;
 }
 
@@ -310,7 +430,7 @@
       if (validateJRE (jre, &req))
       {
         _TCHAR label[MAX_PATH];
-        sprintf (label, _T("Extract %s to:"), req.productName);
+        sprintf (label, _T("Select or create an empty folder to extract %s into:"), req.productName);
 
         _TCHAR* targetFolder = browseForFolder (NULL, label);
         if (targetFolder == NULL)
diff --git a/plugins/org.eclipse.oomph.extractor/src/resources.backup b/plugins/org.eclipse.oomph.extractor/src/resources.backup
new file mode 100644
index 0000000..d82b1d7
--- /dev/null
+++ b/plugins/org.eclipse.oomph.extractor/src/resources.backup
@@ -0,0 +1,17 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Include file generated by Anders Melander's Resource Editor
+//
+//////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Symbol definitions
+//
+
+#define ID_ICON                         101
+#define ID_DLGBOX                       201
+#define IDC_OK                          202
+#define IDC_CB1                         203
+#define IDC_EDIT1                       204
diff --git a/plugins/org.eclipse.oomph.extractor/src/resources.h b/plugins/org.eclipse.oomph.extractor/src/resources.h
index 000b524..835b404 100644
--- a/plugins/org.eclipse.oomph.extractor/src/resources.h
+++ b/plugins/org.eclipse.oomph.extractor/src/resources.h
@@ -1,17 +1,20 @@
-/*
- * Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
+//////////////////////////////////////////////////////////////////////////////
+//
+// Include file generated by Anders Melander's Resource Editor
+//
+//////////////////////////////////////////////////////////////////////////////
 
-#ifndef RESOURCES_H_
-#define RESOURCES_H_
 
-#define ID_ICON 101
+//////////////////////////////////////////////////////////////////////////////
+//
+// Symbol definitions
+//
 
-#endif /* RESOURCES_H_ */
+#define ID_ICON                         101
+
+#define ID_DLGBOX                       201
+#define IDC_OK                          202
+#define IDC_CB1                         203
+#define IDC_EDIT1                       204
+
+#define ID_DLGBOX2                       301
diff --git a/plugins/org.eclipse.oomph.extractor/src/resources.rc b/plugins/org.eclipse.oomph.extractor/src/resources.rc
index 9dfe3f6..36b3aca 100644
--- a/plugins/org.eclipse.oomph.extractor/src/resources.rc
+++ b/plugins/org.eclipse.oomph.extractor/src/resources.rc
@@ -12,3 +12,32 @@
 #include "resources.h"
 
 ID_ICON ICON "..\\..\\..\\products\\org.eclipse.oomph.setup.installer.product\\icons\\oomph.ico"
+
+/*
+ID_DLGBOX DIALOG 100, 100, 380, 90
+CAPTION "Title Bar Text"
+FONT 8, "MS Sans Serif"
+BEGIN
+  PUSHBUTTON "OK",  IDC_OK,      10, 10, 50,  15
+  CHECKBOX "Box 1", IDC_CB1,   10, 30, 50,  15
+  EDITTEXT          IDC_EDIT1, 10, 50, 100, 12
+  CONTROL "OK", 202, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 96, 56, 50, 15
+  CONTROL "", 204, "edit", ES_LEFT | WS_TABSTOP | WS_BORDER | WS_VISIBLE | WS_CHILD, 48, 25, 252, 12
+  CONTROL "The Oomph Installer needs to be extracted into a new folder on your disk.", 0, "static", SS_LEFT | WS_VISIBLE | WS_CHILD, 8, 9, 308, 15
+  CONTROL "Extract to:", 0, "static", SS_LEFT | WS_VISIBLE | WS_CHILD, 8, 26, 40, 13
+  CONTROL IDCANCEL, 202, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 168, 56, 50, 15
+  CONTROL "OK", 202, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 308, 25, 50, 15
+END
+*/
+
+ID_DLGBOX2 DIALOGEX 100, 100, 381, 87
+  CAPTION "Title Bar Text"
+  FONT 8, "MS Sans Serif"
+BEGIN
+  CONTROL "The Oomph Installer needs to be extracted into a new folder on your disk.", 0, "static", SS_LEFT | WS_VISIBLE | WS_CHILD, 8, 9, 308, 15
+  CONTROL "Extract to:", 0, "static", SS_LEFT | WS_VISIBLE | WS_CHILD, 8, 26, 40, 13
+  CONTROL "", 204, "edit", ES_LEFT | WS_TABSTOP | WS_BORDER | WS_VISIBLE | WS_CHILD, 48, 25, 252, 12
+  CONTROL "Browse", 0, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 308, 25, 50, 15
+  CONTROL "OK", 202, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 47, 47, 50, 15
+  CONTROL "Cancel", 0, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE | WS_CHILD, 119, 47, 50, 15
+END