00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #define strict
00012
00013 #include <windows.h>
00014 #include <windowsx.h>
00015 #include <commctrl.h>
00016 #include <string.h>
00017 #include "resource.h"
00018
00019 #include <assert.h>
00020
00021 #include "persistent.h"
00022 #include "eclipselauncher.h"
00023 #include "launcherconfig.h"
00024 #include "clipboard.h"
00025 #include "changeConfigurationDialog.h"
00026 #include "utils.h"
00027
00028
00029 LRESULT MainDialogWindowProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
00030
00031
00032 BOOL OnInitializeApp(HWND hDlg, HWND wParam, LPARAM lParam);
00033 BOOL OnExitApp(HWND hDlg);
00034 BOOL OnCommandHelper(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
00035 void OnDeleteConfiguration(HWND hwnd);
00036 int OnAddNewConfiguration(HWND hwnd);
00037 int OnEditNewConfiguration(HWND hwnd);
00038 void OnLeftButtonDoubleClick(HWND hwnd, BOOL what, int x, int y, UINT keyFlags);
00039 void OnSize(HWND hDialog, int type, int notused1, int notused2);
00040
00041
00042 static WNDPROC gOldListViewWindowProc;
00043 static HWND ghMainDialog;
00044 static BOOL gSendToTray = FALSE;
00045
00046
00047 static NOTIFYICONDATA gNotifyIconData;
00048 static HMENU ghTrayMenu;
00049
00050 #define HEADER_CONFIGURATION_NAME "Configuration Name"
00051 #define HEADER_WORKSPACE_PATH "Workspace Directory"
00052 #define HEADER_VMPARAMETER "VM Parameter"
00053 #define HEADER_JAVAVM "Java VM"
00054
00055 TCHAR* headerLabel[] = { HEADER_CONFIGURATION_NAME, HEADER_WORKSPACE_PATH, HEADER_JAVAVM, HEADER_VMPARAMETER };
00056 int headerLabelSize[] = { 150, 150, 150, 150 };
00057
00065 int APIENTRY WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
00066 {
00067 TCHAR appName[APPNAME_BUFFER_SIZE] = {0};
00068 HWND hDialog;
00069 MSG msg;
00070 WNDCLASS wc;
00071
00072 memset(&wc, 0, sizeof(wc));
00073 wc.lpfnWndProc = DefDlgProc;
00074 wc.cbWndExtra = DLGWINDOWEXTRA;
00075 wc.hInstance = hinst;
00076 wc.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ECLIPSELAUNCHER));
00077 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00078 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
00079 wc.lpszClassName = LocString(IDS_APPNAME, appName);
00080 RegisterClass(&wc);
00081
00082 hDialog = CreateDialog(hinst, MAKEINTRESOURCE(IDD_MAINDIALOG_NOBUTTONS), NULL, (DLGPROC) MainDialogWindowProc);
00083 ListView_SetExtendedListViewStyleEx(GetDlgItem(hDialog, ID_CONFIGLIST), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP , LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP );
00084 if(!hDialog)
00085 {
00086 TCHAR buf[BUFFERSIZE_256];
00087 wsprintf(buf, "Error %ld", GetLastError());
00088 MessageBox(0, buf, "CreateDialog", MB_ICONEXCLAMATION | MB_OK);
00089 return 1;
00090 }
00091
00092 while (GetMessage(&msg, NULL, 0, 0))
00093 {
00094 if (!IsDialogMessage(hDialog, &msg))
00095 {
00096 TranslateMessage(&msg);
00097 DispatchMessage(&msg);
00098 }
00099 }
00100
00101 return msg.wParam;
00102
00103
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 LPLAUNCHERCONFIG hitTestForLauncherConfig(HWND hwnd, int x, int y)
00113 {
00114 LPLAUNCHERCONFIG launcherConfig = NULL;
00115 int listEntryPosition;
00116
00117 LV_HITTESTINFO hitTest = {0};
00118 hitTest.pt.x = x;
00119 hitTest.pt.y = y;
00120 hitTest.flags = LVHT_ONITEM;
00121
00122 listEntryPosition = ListView_HitTest(hwnd, &hitTest);
00123
00124 if(listEntryPosition != (-1))
00125 {
00126
00127 ListView_SetItemState(hwnd, listEntryPosition, LVIS_SELECTED | LVIS_FOCUSED, 0xffff);
00128 launcherConfig = getLauncherConfig(hwnd, listEntryPosition);
00129 }
00130
00131 return(launcherConfig);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140 void showPopupMenu(HMENU hMenu, HWND hMainWindow)
00141 {
00142 POINT cursorPos;
00143 GetCursorPos(&cursorPos);
00144
00145
00146 SetForegroundWindow(hMainWindow);
00147 TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, cursorPos.x, cursorPos.y, 0, hMainWindow, NULL);
00148 PostMessage(hMainWindow, WM_NULL, 0, 0);
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158 int OnRightButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
00159 {
00160 POINT cursorPos;
00161 HMENU hContextMenu;
00162 TCHAR* locbuffer = (TCHAR*) malloc(256);
00163
00164 LPLAUNCHERCONFIG launcherConfig = hitTestForLauncherConfig(hwnd, x, y);
00165
00166 hContextMenu = CreatePopupMenu();
00167
00168 if(launcherConfig != NULL)
00169 {
00170 TCHAR buffer[BUFFERSIZE_256] = {0};
00171
00172 wsprintf(buffer, LocString(IDS_POPUP_EDIT_CONFIGURATION, locbuffer), getName(launcherConfig));
00173 AppendMenu(hContextMenu, MF_STRING, (UINT) IDM_EDITCONFIGURATION,
00174 buffer);
00175
00176 wsprintf(buffer, LocString(IDS_POPUP_DUPLICATE_CONFIGURATION, locbuffer), getName(launcherConfig));
00177 AppendMenu(hContextMenu, MF_STRING, (UINT) IDM_DUPLICATECONFIGURATION,
00178 buffer);
00179
00180 AppendMenu(hContextMenu, MF_MENUBREAK, (UINT) 0,
00181 NULL);
00182
00183 wsprintf(buffer, LocString(IDS_POPUP_DELETE_CONFIGURATION, locbuffer), getName(launcherConfig));
00184 AppendMenu(hContextMenu, MF_STRING, (UINT) IDM_DELETECONFIGURATION,
00185 buffer);
00186 }
00187 else
00188 {
00189 AppendMenu(hContextMenu, MF_STRING, (UINT) IDM_ADDCONFIGURATION,
00190 LocString(IDS_POPUP_ADD_NEW_CONFIGURATION, locbuffer));
00191 }
00192
00193 GetCursorPos(&cursorPos);
00194 TrackPopupMenu(hContextMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, cursorPos.x, cursorPos.y, 0, ghMainDialog, NULL);
00195
00196 free(locbuffer);
00197
00198 return(1);
00199 }
00200
00201
00202
00203
00204
00205
00206
00207 TCHAR* expandEnvironmentVariable(TCHAR* stringToExpand, TCHAR* newBuffer, int bufferSize)
00208 {
00209 TCHAR* startEnvironmentVariable = NULL;
00210 assert(stringToExpand != NULL);
00211
00212 startEnvironmentVariable = strchr(stringToExpand, '%');
00213 if (startEnvironmentVariable != NULL)
00214 {
00215 int startIndex = startEnvironmentVariable - stringToExpand + 1;
00216
00217 TCHAR* endEnvironmentVariable = strrchr(stringToExpand, '%');
00218 if (endEnvironmentVariable != NULL)
00219 {
00220 int endIndex = endEnvironmentVariable - stringToExpand + 1;
00221
00222 TCHAR environmentVariableName[BUFFERSIZE_512] = {0};
00223 TCHAR environmentVariableValue[BUFFERSIZE_512] = {0};
00224
00225 strncpy(environmentVariableName, stringToExpand + startIndex, endIndex - startIndex - 1);
00226 GetEnvironmentVariable(environmentVariableName, environmentVariableValue, 512);
00227
00228 lstrcpyn(newBuffer, stringToExpand, startIndex);
00229 strcat(newBuffer, environmentVariableValue);
00230 strcat(newBuffer, stringToExpand + endIndex);
00231 }
00232 }
00233 else
00234 {
00235 lstrcpyn(newBuffer, stringToExpand, bufferSize);
00236 }
00237
00238 return newBuffer;
00239 }
00240
00241
00242
00243
00244
00245
00246
00247 void executeLaunchConfiguration(LPLAUNCHERCONFIG launcherConfiguration)
00248 {
00249 int CMDLineLength = 4096;
00250 TCHAR* commandline = (TCHAR*)malloc(CMDLineLength);
00251 ZeroMemory(commandline, CMDLineLength);
00252
00253 assert(launcherConfiguration != NULL);
00254
00255 if(lstrlen(getWorkspacePath(launcherConfiguration)) > 0)
00256 {
00257 TCHAR tempBuffer[BUFFERSIZE_512] = {0};
00258 wsprintf(commandline, "%s %s %s %s", expandEnvironmentVariable(getExecutablePath(launcherConfiguration), tempBuffer, 512),
00259 "-showlocation -data",
00260 getWorkspacePath(launcherConfiguration),
00261 getOptionalParameter(launcherConfiguration));
00262 }
00263 else
00264 {
00265 TCHAR tempBuffer[BUFFERSIZE_512] = {0};
00266 wsprintf(commandline, "%s %s %s", expandEnvironmentVariable(getExecutablePath(launcherConfiguration), tempBuffer, 512),
00267 "-showlocation",
00268 getOptionalParameter(launcherConfiguration));
00269 }
00270
00271 if(lstrlen(getJavaVM(launcherConfiguration)) > 0)
00272 {
00273 TCHAR tempBuffer[BUFFERSIZE_512 * 2] = {0};
00274 wsprintf(tempBuffer, " -vm %s", getJavaVM(launcherConfiguration));
00275 lstrcat(commandline, tempBuffer);
00276 }
00277
00278 if(lstrlen(getVMParameter(launcherConfiguration)) > 0)
00279 {
00280 TCHAR tempBuffer[BUFFERSIZE_512 * 2] = {0};
00281 wsprintf(tempBuffer, " -vmargs %s", getVMParameter(launcherConfiguration));
00282 lstrcat(commandline, tempBuffer);
00283 }
00284
00285 ShowWindow(ghMainDialog, SW_HIDE);
00286
00287
00288 if(WinExec(commandline, SW_SHOW) > 31)
00289 {
00290
00291 }
00292 else
00293 {
00294 TCHAR messageBuffer[BUFFERSIZE_512] = {0};
00295 TCHAR locString[BUFFERSIZE_256] = {0};
00296 wsprintf(messageBuffer, "%s\n%s", LocString(IDS_ERROR_EXECUTING_CONFIGURATION, locString), commandline);
00297 MessageBox(ghMainDialog, messageBuffer, "Error during Execution", MB_ICONEXCLAMATION | MB_OK);
00298 }
00299
00300 free(commandline);
00301 }
00302
00303
00304
00305
00306
00307
00308
00309 void OnLeftButtonDoubleClick(HWND hwnd, BOOL what, int x, int y, UINT keyFlags)
00310 {
00311 LPLAUNCHERCONFIG launcherConfig = hitTestForLauncherConfig(hwnd, x, y);
00312
00313 if(launcherConfig != NULL)
00314 {
00315
00316 if((keyFlags & MK_CONTROL) == MK_CONTROL)
00317 {
00318 OnEditNewConfiguration(ghMainDialog);
00319 }
00320 else
00321 {
00322 executeLaunchConfiguration(launcherConfig);
00323 }
00324 }
00325 }
00326
00330 void OnKeyPressed(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
00331 {
00332 switch(vk)
00333 {
00334 case VK_DELETE:
00335 {
00336 OnDeleteConfiguration(hwnd);
00337 }
00338 break;
00339
00340 case VK_INSERT:
00341 {
00342 OnAddNewConfiguration(ghMainDialog);
00343 }
00344 break;
00345 }
00346 }
00347
00352 LRESULT ListViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00353 {
00354 switch (msg)
00355 {
00356 HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK, OnLeftButtonDoubleClick);
00357 HANDLE_MSG(hwnd, WM_RBUTTONDOWN, OnRightButtonDown);
00358 HANDLE_MSG(hwnd, WM_KEYUP, OnKeyPressed);
00359 }
00360
00361 return(CallWindowProc(gOldListViewWindowProc, hwnd, msg, wParam, lParam));
00362 }
00363
00368 void setUpTrayIcon(HWND hDialog)
00369 {
00370 TCHAR buffer[BUFFERSIZE_256] = {0};
00371
00372 ghTrayMenu = LoadMenu(getApplicationInstance(), MAKEINTRESOURCE(ID_TRAYMENU));
00373
00374 gNotifyIconData.cbSize = sizeof(NOTIFYICONDATA);
00375 gNotifyIconData.hWnd = hDialog;
00376 gNotifyIconData.uID = 0;
00377 gNotifyIconData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
00378 gNotifyIconData.uCallbackMessage = WM_USER;
00379 gNotifyIconData.hIcon = LoadImage(getApplicationInstance(), MAKEINTRESOURCE(IDI_ECLIPSELAUNCHER), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
00380 lstrcpy(gNotifyIconData.szTip, LocString(IDS_POPUP_ENABLE_HINT, buffer));
00381
00382 Shell_NotifyIcon(NIM_ADD, &gNotifyIconData);
00383 }
00384
00389 void setUpListViewHeader(HWND hDialog)
00390 {
00391 HWND hListBox;
00392 int headerCount;
00393 int headers = sizeof(headerLabel) / sizeof(headerLabel[0]);
00394
00395 LV_COLUMN column = {0};
00396
00397 column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
00398 column.cx = 150;
00399 column.fmt = LVCFMT_LEFT;
00400
00401 hListBox = GetDlgItem(hDialog, ID_CONFIGLIST);
00402
00403 for(headerCount = 0; headerCount < headers; headerCount++)
00404 {
00405 column.pszText = headerLabel[headerCount];
00406 column.cx = headerLabelSize[headerCount];
00407 ListView_InsertColumn(hListBox, headerCount, &column);
00408 }
00409 }
00410
00411
00412
00413
00414
00415 BOOL OnInitializeApp(HWND hDlg, HWND wParam, LPARAM lParam)
00416 {
00417 TCHAR appNameVersion[BUFFERSIZE_256] = {0};
00418 TCHAR appName[APPNAME_BUFFER_SIZE] = {0};
00419 TCHAR appVersion[APPVERSION_BUFFER_SIZE] = {0};
00420
00421 HWND hListBox = GetDlgItem(hDlg, ID_CONFIGLIST);
00422
00423 wsprintf(appNameVersion, "%s %s", LocString(IDS_APPNAME, appName), LocString(IDS_APPVERSION, appVersion));
00424
00425 setUpListViewHeader(hDlg);
00426
00427 loadConfiguration(hListBox);
00428
00429
00430
00431
00432 gOldListViewWindowProc = (WNDPROC)GetWindowLong(hListBox, GWL_WNDPROC);
00433 SetWindowLong(hListBox, GWL_WNDPROC, (LONG)ListViewWindowProc);
00434
00435 SetWindowText(hDlg, appNameVersion);
00436
00437 setUpTrayIcon(hDlg);
00438
00439 ShowWindow(hDlg, SW_HIDE);
00440
00441 return TRUE;
00442 }
00443
00448 BOOL OnExitApp(HWND hDlg)
00449 {
00450
00451 Shell_NotifyIcon(NIM_DELETE, &gNotifyIconData);
00452
00453 disposeAllConfigurations(GetDlgItem(hDlg, ID_CONFIGLIST));
00454
00455 DestroyMenu(ghTrayMenu);
00456
00457 EndDialog(hDlg,0);
00458 return TRUE;
00459 }
00460
00461
00462
00463
00464 void OnDeleteConfiguration(HWND hListBox)
00465 {
00466 int currentSelection = getCurrentSelection(hListBox);
00467 if(currentSelection != LB_ERR)
00468 {
00469 LPLAUNCHERCONFIG data = getLauncherConfig(hListBox, currentSelection);
00470 int result;
00471 TCHAR resString[STRINGBUFFER_SIZE];
00472 TCHAR message[STRINGBUFFER_SIZE];
00473 TCHAR dialogTitle[STRINGBUFFER_SIZE];
00474
00475 wsprintf(message, LocString(IDS_REMOVE_CONFIGURATION, resString), getName(data));
00476
00477 LocString(IDS_REMOVE_CONFIGURATION_TITLE, resString);
00478 wsprintf(dialogTitle, resString);
00479
00480 result = MessageBox(NULL, message, dialogTitle, MB_YESNO);
00481 if(IDYES == result)
00482 {
00483 releaseLauncherConfig(data);
00484 ListView_DeleteItem(hListBox, currentSelection);
00485 saveConfiguration(hListBox);
00486 }
00487 }
00488 }
00489
00494 void restoreWindow(HWND hWindow)
00495 {
00496 ShowWindow(hWindow, SW_SHOWNORMAL);
00497 SetForegroundWindow(hWindow);
00498 }
00499
00500
00505 BOOL OnCommandHelper(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
00506 {
00507
00508 if (codeNotify == 0)
00509 {
00510 switch (id)
00511 {
00512 case IDCANCEL:
00513 {
00514 EndDialog(hwnd, 0);
00515 return 1;
00516 }
00517 break;
00518
00519 case ID_TRAYEXIT:
00520 {
00521 gSendToTray = FALSE;
00522 EndDialog(hwnd,0);
00523 SendMessage(hwnd, WM_DESTROY, 0, 0);
00524 return TRUE;
00525 }
00526
00527 case IDM_ADDCONFIGURATION:
00528 case ID_ADDCONFIGURATION:
00529 {
00530 return(OnAddNewConfiguration(hwnd));
00531 }
00532
00533 case IDM_EDITCONFIGURATION:
00534 case ID_EDITCONFIGURATION:
00535 {
00536 return(OnEditNewConfiguration(hwnd));
00537 }
00538
00539 case IDM_DUPLICATECONFIGURATION:
00540 {
00541 HWND hListbox = GetDlgItem(hwnd, ID_CONFIGLIST);
00542 OnDuplicateLaunchConfiguration(hListbox);
00543 }
00544 break;
00545
00546 case IDM_DELETECONFIGURATION:
00547 case ID_DELETECONFIG:
00548 {
00549 HWND hListBox = GetDlgItem(hwnd, ID_CONFIGLIST);
00550 OnDeleteConfiguration(hListBox);
00551 return TRUE;
00552 }
00553
00554 case ID_RESTOREFROMTRAY:
00555 {
00556 restoreWindow(hwnd);
00557 }
00558 break;
00559
00560 case ID_ABOUT:
00561 {
00562 TCHAR appAbout[BUFFERSIZE_512] = {0};
00563 TCHAR appVersionString[BUFFERSIZE_512 * 2] = {0};
00564 TCHAR appName[APPNAME_BUFFER_SIZE] = {0};
00565 TCHAR appVersion[APPVERSION_BUFFER_SIZE] = {0};
00566
00567 LocString(APP_ABOUT, appAbout);
00568 LocString(IDS_APPNAME, appName);
00569 LocString(IDS_APPVERSION, appVersion);
00570
00571 wsprintf(appVersionString, "%s %s\n%s", appName, appVersion, appAbout);
00572 MessageBox(hwnd, appVersionString, "About EclipseLauncher", MB_OK | MB_ICONEXCLAMATION);
00573 }
00574 break;
00575
00576
00577 default:
00578 {
00579 int launcherConfigNum = id - IDM_EXECUTECONFIGURATION;
00580 LPLAUNCHERCONFIG launcherConfig = getLauncherConfig(GetDlgItem(hwnd, ID_CONFIGLIST), launcherConfigNum);
00581 executeLaunchConfiguration(launcherConfig);
00582 }
00583 }
00584 }
00585
00586 return TRUE;
00587 }
00588
00589 void OnSize(HWND hDialog, int type, int notused1, int notused2)
00590 {
00591 if(type == SIZE_MINIMIZED)
00592 {
00593 ShowWindow(hDialog, SW_HIDE);
00594 }
00595 }
00596
00597 BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
00598 {
00599 lpCreateStruct->style &= WS_MINIMIZE;
00600
00601 return 0;
00602 }
00603
00608 void OnSysCommand(HWND hDialog, UINT cmd, int x, int y)
00609 {
00610 if(cmd == SC_MINIMIZE || cmd == SC_CLOSE)
00611 {
00612 ShowWindow(hDialog, SW_HIDE);
00613 gSendToTray = TRUE;
00614 }
00615 }
00616
00625 LRESULT MainDialogWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00626 {
00627 static HWND editLabelControl;
00628 ghMainDialog = hwnd;
00629
00630 switch (msg)
00631 {
00632 HANDLE_MSG(hwnd, WM_CREATE, OnCreate);
00633 HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitializeApp);
00634 HANDLE_MSG(hwnd, WM_COMMAND, OnCommandHelper);
00635 HANDLE_MSG(hwnd, WM_SYSCOMMAND, OnSysCommand);
00636 HANDLE_MSG(hwnd, WM_SIZE, OnSize);
00637
00638 case WM_NOTIFY:
00639 {
00640 int idCtrl = (int) wParam;
00641 LPNMHDR pnmh = (LPNMHDR) lParam;
00642
00643 switch(pnmh->code)
00644 {
00645 case LVN_BEGINLABELEDIT:
00646 {
00647 editLabelControl = ListView_GetEditControl(pnmh->hwndFrom);
00648 return FALSE;
00649 }
00650 break;
00651
00652 case LVN_ENDLABELEDIT:
00653 {
00654 char text[255]="";
00655 HWND hListView = pnmh->hwndFrom;
00656 int iIndex = SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
00657 LPLAUNCHERCONFIG data = getLauncherConfig(hListView, iIndex);
00658
00659 GetWindowText(editLabelControl, text, sizeof(text));
00660 setName(data, text, sizeof(text));
00661 updateLauchnerConfig(hListView, data, iIndex);
00662 saveConfiguration(hListView);
00663 }
00664 break;
00665
00666 case LVN_GETINFOTIP:
00667 {
00668 TCHAR* tempValue;
00669 TCHAR buffer[BUFFERSIZE_512*2] = {0};
00670 LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam;
00671 LPLAUNCHERCONFIG data = getLauncherConfig(pGetInfoTip->hdr.hwndFrom, pGetInfoTip->iItem);
00672
00673 wsprintf(buffer, "Name:\t\t%s\nExecutable:\t%s", getName(data), getExecutablePath(data));
00674
00675 tempValue = getJavaVM(data);
00676
00677 if (lstrlen(tempValue))
00678 {
00679 lstrcat(buffer, "\nJavaVM:\t");
00680 lstrcat(buffer, tempValue);
00681 }
00682
00683 tempValue = getWorkspacePath(data);
00684 if (lstrlen(tempValue))
00685 {
00686 lstrcat(buffer, "\nWorkspace:\t");
00687 lstrcat(buffer, tempValue);
00688 }
00689
00690 tempValue = getOptionalParameter(data);
00691 if (lstrlen(tempValue))
00692 {
00693 lstrcat(buffer, "\nParameter:\t");
00694 lstrcat(buffer, tempValue);
00695 }
00696
00697 tempValue = getVMParameter(data);
00698 if (lstrlen(tempValue))
00699 {
00700 lstrcat(buffer, "\nVM Parameter:\t");
00701 lstrcat(buffer, tempValue);
00702 }
00703
00704 lstrcpy(pGetInfoTip->pszText, buffer);
00705 }
00706 }
00707 }
00708 break;
00709
00710 case WM_DESTROY:
00711 {
00712 if( gSendToTray != TRUE)
00713 {
00714 OnExitApp(hwnd);
00715 PostQuitMessage(0);
00716 }
00717 }
00718 break;
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 case WM_USER:
00819 {
00820 switch(lParam)
00821 {
00822
00823 case WM_RBUTTONUP:
00824 {
00825 HWND hConfigList = GetDlgItem(hwnd, ID_CONFIGLIST);
00826 int configurationCount = getConfigurationCount(hConfigList);
00827 HMENU hSubMenu = GetSubMenu(ghTrayMenu, 0);
00828 LPLAUNCHERCONFIG launcherConfig;
00829
00830 int configurationNum;
00831 int menuItemCount = GetMenuItemCount(hSubMenu);
00832 int itemCount;
00833 int flags;
00834 MENUITEMINFO menuiteminfo = {0};
00835 menuiteminfo.cbSize = sizeof(MENUITEMINFO);
00836 menuiteminfo.fMask = MIIM_ID;
00837
00838 for(itemCount = 0; itemCount < menuItemCount; itemCount++)
00839 {
00840
00841 GetMenuItemInfo(hSubMenu, 0, TRUE, &menuiteminfo);
00842
00843 if(menuiteminfo.wID == (UINT)(IDM_EXECUTECONFIGURATION + itemCount))
00844 {
00845 DeleteMenu(hSubMenu, 0, MF_BYPOSITION);
00846 }
00847
00848 if(menuiteminfo.wID == 9999)
00849 {
00850 DeleteMenu(hSubMenu, 0, MF_BYPOSITION);
00851 break;
00852 }
00853 }
00854
00855 for(configurationNum = 0; configurationNum < configurationCount; configurationNum++)
00856 {
00857 launcherConfig = getLauncherConfig(hConfigList, configurationNum);
00858
00859
00860
00861
00862 flags = MF_BYPOSITION;
00863
00864 if(! lockfileIsDeleteable(getWorkspacePath(launcherConfig)))
00865 {
00866 flags |= MF_CHECKED;
00867 }
00868
00869 InsertMenu(hSubMenu, configurationNum, flags, (UINT) IDM_EXECUTECONFIGURATION + configurationNum,
00870 getName(launcherConfig));
00871 }
00872
00873 InsertMenu(hSubMenu, configurationNum, MF_BYPOSITION, 9999, NULL);
00874
00875 showPopupMenu(hSubMenu, hwnd);
00876
00877 return TRUE;
00878 }
00879 break;
00880
00881 case WM_LBUTTONDBLCLK:
00882 {
00883 restoreWindow(hwnd);
00884 return TRUE;
00885 }
00886 break;
00887 }
00888 }
00889 break;
00890 }
00891
00892 return FALSE;
00893 }
00894
00895 int OnAddNewConfiguration(HWND hwnd)
00896 {
00897 return(DialogBoxParam(getApplicationInstance(),
00898 MAKEINTRESOURCE(IDD_ADDCONFIGDLG),
00899 hwnd,
00900 (DLGPROC) HandleAddConfigurationDialogProc,
00901 MAKELPARAM(NULL, GetDlgItem(hwnd, ID_CONFIGLIST))));
00902 }
00903
00904 int OnEditNewConfiguration(HWND hwnd)
00905 {
00906 return(DialogBoxParam(getApplicationInstance(),
00907 MAKEINTRESOURCE(IDD_ADDCONFIGDLG),
00908 hwnd,
00909 (DLGPROC) HandleEditConfigurationDialogProc,
00910 MAKELPARAM(NULL, GetDlgItem(hwnd, ID_CONFIGLIST))));
00911 }
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934