diff options
Diffstat (limited to 'storage/ndb/src/cw/cpcc-win32')
40 files changed, 8165 insertions, 0 deletions
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp new file mode 100644 index 00000000000..b1d599dda63 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp @@ -0,0 +1,214 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "stdafx.h" + +HINSTANCE hInst ; +TCHAR szTitle[MAX_LOADSTRING] ; +TCHAR szWindowClass[MAX_LOADSTRING] ; + +static CNdbControls controls ; + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow){ + MSG msg; + HACCEL hAccelTable; + + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING) ; + LoadString(hInstance, IDC_CPC_GUI, szWindowClass, MAX_LOADSTRING) ; + NdbRegisterClass(hInstance); + + if (!InitInstance (hInstance, nCmdShow)) { + return FALSE; + } + + hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_CPC_GUI); + + while (GetMessage(&msg, NULL, 0, 0)){ + + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){ + + TranslateMessage(&msg); + DispatchMessage(&msg); + + } + + } + + return msg.wParam; +} + + +ATOM NdbRegisterClass(HINSTANCE hInstance){ + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW ; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_CPC_GUI); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW); + wcex.lpszMenuName = (LPCSTR)IDC_CPC_GUI; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + return RegisterClassEx(&wcex); +} + + +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){ + + HWND hWnd; + + hInst = hInstance; + + hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + InitCommonControls(); + + if (!hWnd) return FALSE ; + + ShowWindow(hWnd, nCmdShow) ; + UpdateWindow(hWnd) ; + + return TRUE; +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ + + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; + int c = 0 ; + + switch (message) + { + + case WM_CREATE: + _assert(controls.Create(hInst, hWnd)) ; + return 0 ; + + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + + switch (wmId){ + case IDM_ABOUT: + DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR) lParam)->code) { + case TTN_GETDISPINFO: { + + LPTOOLTIPTEXT lpttt; + lpttt = (LPTOOLTIPTEXT) lParam; + lpttt->hinst = hInst; + + int idButton = lpttt->hdr.idFrom; + + switch (idButton){ + case IDM_NEW: + lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_NEW); + break; + case IDM_DELETE: + lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_DELETE); + break; + case IDM_PROPS: + lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_PROPS); + break; + } + break; + } + case TVN_SELCHANGED: { + LPNMTREEVIEW pnmtv ; + + pnmtv = (LPNMTREEVIEW) lParam ; + controls.ToggleListViews(pnmtv) ; + + break ; + } + + case NM_RCLICK: { + LPNMHDR lpnmh ; + lpnmh = (LPNMHDR) lParam ; + switch(lpnmh->idFrom){ + case ID_TREEVIEW: + break; + default: + break ; + } + } + + default: + break; + } + + + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps) ; + EndPaint(hWnd, &ps); + break; + + case WM_SIZE: + controls.Resize() ; + return 0 ; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + + +LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){ + + switch (message){ + + case WM_INITDIALOG: + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){ + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + } + break; + } + return FALSE; +} + + + + + diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp new file mode 100644 index 00000000000..91007b0a47e --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp @@ -0,0 +1,216 @@ +# Microsoft Developer Studio Project File - Name="CPC_GUI" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=CPC_GUI - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "CPC_GUI.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "CPC_GUI.mak" CFG="CPC_GUI - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "CPC_GUI - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "CPC_GUI - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "CPC_GUI - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc42.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "CPC_GUI - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib comctl32.lib mfc42d.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "CPC_GUI - Win32 Release" +# Name "CPC_GUI - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\CPC_GUI.cpp +# End Source File +# Begin Source File + +SOURCE=.\CPC_GUI.rc +# End Source File +# Begin Source File + +SOURCE=.\NdbControls.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\CPC_GUI.h +# End Source File +# Begin Source File + +SOURCE=.\NdbControls.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\bitmap1.bmp +# End Source File +# Begin Source File + +SOURCE=.\bmp00001.bmp +# End Source File +# Begin Source File + +SOURCE=.\C.bmp +# End Source File +# Begin Source File + +SOURCE=.\Closed.BMP +# End Source File +# Begin Source File + +SOURCE=.\Closed.ICO +# End Source File +# Begin Source File + +SOURCE=.\Closed24.bmp +# End Source File +# Begin Source File + +SOURCE=.\Computer24.BMP +# End Source File +# Begin Source File + +SOURCE=.\CPC_GUI.ico +# End Source File +# Begin Source File + +SOURCE=.\Db.bmp +# End Source File +# Begin Source File + +SOURCE=.\icon1.ico +# End Source File +# Begin Source File + +SOURCE=.\O.bmp +# End Source File +# Begin Source File + +SOURCE=.\Open.BMP +# End Source File +# Begin Source File + +SOURCE=.\Open.ICO +# End Source File +# Begin Source File + +SOURCE=.\Open24.bmp +# End Source File +# Begin Source File + +SOURCE=.\small.ico +# End Source File +# Begin Source File + +SOURCE=.\toolbar.bmp +# End Source File +# Begin Source File + +SOURCE=.\toolbar1.bmp +# End Source File +# Begin Source File + +SOURCE=.\Tower2.ICO +# End Source File +# Begin Source File + +SOURCE=.\TowerIC1.BMP +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw new file mode 100644 index 00000000000..1f163a31662 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "CPC_GUI"=.\CPC_GUI.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h new file mode 100644 index 00000000000..692248cf9ea --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#if !defined(AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_) +#define AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +#define MAX_LOADSTRING 100 + + + +#define TV_ROOT_ITEMS 2 + + +// Global Variables + +ATOM NdbRegisterClass(HINSTANCE) ; +BOOL InitInstance(HINSTANCE, int) ; +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ; +LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +#endif // !defined(AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_) diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico Binary files differnew file mode 100644 index 00000000000..386883523bc --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc new file mode 100644 index 00000000000..41d75b2b282 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc @@ -0,0 +1,193 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_CPC_GUI ICON DISCARDABLE "CPC_GUI.ICO" +IDI_SMALL ICON DISCARDABLE "SMALL.ICO" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDM_CPC_GUI MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Actions" + BEGIN + MENUITEM "&Insert...", ID_ACTIONS_INSERT + MENUITEM "&Delete", ID_ACTIONS_DELETE + MENUITEM "&Properties", ID_ACTIONS_PROPERTIES + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END +END + +IDM_TREEVIEW MENU DISCARDABLE +BEGIN + MENUITEM "&Insert", ID_TREEVIEW1 + MENUITEM "&Delete", ID_DELETE + MENUITEM "&Properties", ID_PROPERTIES +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_CPC_GUI ACCELERATORS MOVEABLE PURE +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "NDB Cluster Process Control Applet v1.0",IDC_STATIC,7,8, + 213,8,SS_NOPREFIX + LTEXT "Copyright (C) 2003 MySQL AB", + IDC_STATIC,7,20,213,20 + DEFPUSHBUTTON "OK",IDOK,185,55,41,16,WS_GROUP +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE MOVEABLE PURE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE MOVEABLE PURE +BEGIN + "\r\n" + "\0" +END + +1 TEXTINCLUDE MOVEABLE PURE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_TOOLBAR BITMAP MOVEABLE PURE "toolbar.bmp" +IDB_TOOLBAR BITMAP MOVEABLE PURE "bitmap1.bmp" +IDB_COMPUTER BITMAP MOVEABLE PURE "TowerIC1.BMP" +IDB_OPEN BITMAP MOVEABLE PURE "Open.BMP" +IDB_CLOSED BITMAP MOVEABLE PURE "Closed.BMP" +IDB_DATABASE BITMAP MOVEABLE PURE "DB.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_TOOLBAR TOOLBAR MOVEABLE PURE 18, 18 +BEGIN + BUTTON ID_BUTTON32773 + BUTTON ID_BUTTON32783 + BUTTON ID_BUTTON32784 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "NDB Cluster Process Control Applet" + IDS_TV_ROOT_COMPUTERS "Computers" + IDS_TV_ROOT_DATABASES "Databases" + IDS_LV_COMPUTER_HEADER_1 "Computer" + IDS_LV_COMPUTER_HEADER_2 "Hostname" + IDS_LV_PROCESS_HEADER_1 "Process" + IDC_CPC_GUI "CPC_GUI" + IDS_TIP_NEW "Add new computer or database" + IDS_TIP_DELETE "Delete selected computer or database" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TIP_PROPS "Display properties for selected computer or database" + IDS_LV_PROCESS_HEADER_2 "Name" + IDS_LV_PROCESS_HEADER_3 "Owner" + IDS_LV_PROCESS_HEADER_4 "Status" + IDS_LV_COMPUTER_HEADER_3 "Status" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln new file mode 100644 index 00000000000..86b574d851d --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPC_GUI", "CPC_GUI.vcproj", "{F5FADD9D-4353-4A73-88DC-474A4D17B485}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Debug.ActiveCfg = Debug|Win32 + {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Debug.Build.0 = Debug|Win32 + {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Release.ActiveCfg = Release|Win32 + {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo Binary files differnew file mode 100644 index 00000000000..e7d178f04c3 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj new file mode 100644 index 00000000000..fb1e2fd601c --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj @@ -0,0 +1,240 @@ +<?xml version="1.0" encoding = "Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.00" + Name="CPC_GUI" + SccProjectName="" + SccLocalPath=""> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory=".\release_obj" + IntermediateDirectory=".\release_obj" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" + StringPooling="TRUE" + RuntimeLibrary="4" + EnableFunctionLevelLinking="TRUE" + UsePrecompiledHeader="3" + PrecompiledHeaderThrough="stdafx.h" + PrecompiledHeaderFile=".\release_obj/CPC_GUI.pch" + AssemblerListingLocation=".\release_obj/" + ObjectFile=".\release_obj/" + ProgramDataBaseFileName=".\release_obj/" + WarningLevel="3" + SuppressStartupBanner="TRUE"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="/MACHINE:I386" + AdditionalDependencies="mfc42.lib" + OutputFile=".\release_obj/CPC_GUI.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + ProgramDatabaseFile=".\release_obj/CPC_GUI.pdb" + SubSystem="2"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="NDEBUG" + MkTypLibCompatible="TRUE" + SuppressStartupBanner="TRUE" + TargetEnvironment="1" + TypeLibraryName=".\release_obj/CPC_GUI.tlb"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="1033"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + </Configuration> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\debug_obj" + IntermediateDirectory=".\debug_obj" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + UsePrecompiledHeader="3" + PrecompiledHeaderThrough="stdafx.h" + PrecompiledHeaderFile=".\debug_obj/CPC_GUI.pch" + AssemblerListingLocation=".\debug_obj/" + ObjectFile=".\debug_obj/" + ProgramDataBaseFileName=".\debug_obj/" + BrowseInformation="1" + WarningLevel="3" + SuppressStartupBanner="TRUE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="/MACHINE:I386" + AdditionalDependencies="comctl32.lib mfc70d.lib" + OutputFile=".\debug_obj/CPC_GUI.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile=".\debug_obj/CPC_GUI.pdb" + SubSystem="2"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="_DEBUG" + MkTypLibCompatible="TRUE" + SuppressStartupBanner="TRUE" + TargetEnvironment="1" + TypeLibraryName=".\debug_obj/CPC_GUI.tlb"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="1033"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + </Configuration> + </Configurations> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> + <File + RelativePath=".\CPC_GUI.cpp"> + </File> + <File + RelativePath=".\CPC_GUI.rc"> + </File> + <File + RelativePath=".\NdbControls.cpp"> + </File> + <File + RelativePath=".\StdAfx.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1"/> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl"> + <File + RelativePath=".\CPC_GUI.h"> + </File> + <File + RelativePath=".\NdbControls.h"> + </File> + <File + RelativePath=".\StdAfx.h"> + </File> + <File + RelativePath=".\resource.h"> + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> + <File + RelativePath=".\C.bmp"> + </File> + <File + RelativePath=".\CPC_GUI.ico"> + </File> + <File + RelativePath=".\Closed.BMP"> + </File> + <File + RelativePath=".\Closed.ICO"> + </File> + <File + RelativePath=".\Closed24.bmp"> + </File> + <File + RelativePath=".\Computer24.BMP"> + </File> + <File + RelativePath=".\Db.bmp"> + </File> + <File + RelativePath=".\O.bmp"> + </File> + <File + RelativePath=".\Open.BMP"> + </File> + <File + RelativePath=".\Open.ICO"> + </File> + <File + RelativePath=".\Open24.bmp"> + </File> + <File + RelativePath=".\Tower2.ICO"> + </File> + <File + RelativePath=".\TowerIC1.BMP"> + </File> + <File + RelativePath=".\bitmap1.bmp"> + </File> + <File + RelativePath=".\bmp00001.bmp"> + </File> + <File + RelativePath=".\icon1.ico"> + </File> + <File + RelativePath=".\small.ico"> + </File> + <File + RelativePath=".\toolbar.bmp"> + </File> + <File + RelativePath=".\toolbar1.bmp"> + </File> + </Filter> + <File + RelativePath=".\ReadMe.txt"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO b/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO Binary files differnew file mode 100644 index 00000000000..044042b42fb --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO diff --git a/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp new file mode 100644 index 00000000000..8feadf9462c --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp @@ -0,0 +1,435 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "stdafx.h" +#include "NdbControls.h" + + +/** +* CNdbControl implementation +*/ + +BOOL CNdbControl::GetRect(LPRECT lprc) const { + + _ASSERT(this) ; + + return GetClientRect(m_hControl, lprc) ; + +} + +BOOL CNdbControl::Resize(LONG x, LONG y, LONG w, LONG h) const { + + _ASSERT(this) ; + + if(!MoveWindow(m_hControl, x, y, w, h, TRUE)) + return FALSE ; + if(m_bVisible){ + ShowWindow(m_hControl, SW_SHOW) ; + UpdateWindow(m_hControl) ; + } + return TRUE ; + +} + +BOOL CNdbControl::Show(BOOL bShow) { + + _ASSERT(this) ; + + if(bShow){ + ShowWindow(m_hControl, SW_SHOW); + m_bVisible = TRUE ; + }else{ + ShowWindow(m_hControl, SW_HIDE); + m_bVisible = FALSE ; + } + EnableWindow(m_hControl, bShow) ; + UpdateWindow(m_hControl) ; + + return TRUE ; +} + + + +CNdbControl::~CNdbControl(){ + + DestroyWindow(m_hControl) ; + if(m_hMenu) + DestroyMenu(m_hMenu) ; + +} + + +/** +* CNdbListView implementation +*/ + +BOOL CNdbListView::Create(HINSTANCE hInst, HWND hParent, DWORD dwId, NDB_ITEM_TYPE enType, PNDB_LV pstH, DWORD dwWidth) { + + if(!pstH) + return FALSE ; + + LV_COLUMN lvC ; + m_hInstance = hInst ; + m_hParent = hParent ; + m_dwId = dwId ; + m_dwWidth = dwWidth ; + m_dwWidth = 100 ; + m_enType = enType; + char* szLabels[MAX_LV_HEADERS] ; + int count = 0 ; + + m_hControl = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, WC_LISTVIEW, TEXT(""), + WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT, + 0, 0, 0, 0, m_hParent, (HMENU)m_dwId, hInst, NULL ); + + if(!m_hControl) + return FALSE ; + + lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvC.fmt = LVCFMT_LEFT; + + switch(enType){ + case ITEM_COMPR_ROOT: + szLabels[0] = pstH->szComputer ; + szLabels[1] = pstH->szHostname ; + szLabels[2] = pstH->szStatus ; + count = 3 ; + break ; + case ITEM_DB_ROOT: + szLabels[0] = pstH->szDatabase ; + szLabels[1] = pstH->szStatus ; + count = 2 ; + break ; + case ITEM_COMPR: + szLabels[0] = pstH->szProcess ; + szLabels[1] = pstH->szDatabase; + szLabels[2] = pstH->szOwner ; + szLabels[3] = pstH->szStatus ; + count = 4 ; + case ITEM_DB: + szLabels[0] = pstH->szProcess ; + szLabels[1] = pstH->szComputer; + szLabels[2] = pstH->szOwner ; + szLabels[3] = pstH->szStatus ; + count = 4 ; + break ; + NDB_DEFAULT_UNREACHABLE ; + } + + for(int j = 0 ; j < count ; ++j){ + lvC.iSubItem = j ; + lvC.cx = m_dwWidth ; + lvC.pszText = szLabels[j] ; + if(0xFFFFFFFF == ListView_InsertColumn(m_hControl, j, &lvC)) + return FALSE ; + } + + SendMessage(m_hControl, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, + LVS_EX_FULLROWSELECT ); + + ShowWindow(m_hControl, SW_SHOW) ; + + return TRUE ; + +} + + + +/** +* CNdbToolBar implementation +*/ + + + +/** +* CNdbTreeView implementation +*/ + +BOOL CNdbTreeView::Create(HINSTANCE hInst, HWND hParent, DWORD dwMenuId, DWORD dwId){ + + if(!CreateTreeView(hInst, hParent, dwId)) + return FALSE ; + + m_hMenu = LoadMenu(m_hInstance,MAKEINTRESOURCE(dwMenuId)) ; + if(!m_hMenu) + return FALSE ; + + return TRUE ; +} + + +BOOL CNdbTreeView::CreateTreeView(HINSTANCE hInst, HWND hParent, DWORD dwId){ + + + m_hInstance = hInst ; + m_hParent = hParent ; + m_dwId = dwId ; + HIMAGELIST himl ; + HBITMAP hbmp ; + DWORD dwCount = 0 ; + + m_hControl = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, WC_TREEVIEW, "Tree View", + WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES | + TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SINGLEEXPAND, + 0, 0, 0, 0, m_hParent, (HMENU)m_dwId, m_hInstance, NULL) ; + + if(!m_hControl) + return FALSE ; + + if((himl = ImageList_Create(nX, nY, ILC_MASK | ILC_COLOR8, 4, 0)) == NULL) + return FALSE ; + + hbmp = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDI_OPEN)); + hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_OPEN), IMAGE_BITMAP, nX, 0, LR_DEFAULTSIZE); + m_nOpen = ImageList_AddMasked(himl, hbmp, clr); + DeleteObject(hbmp); + hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_CLOSED), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); + m_nClosed = ImageList_AddMasked(himl, hbmp, clr); + DeleteObject(hbmp); + hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_COMPUTER),IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); + m_nComputer = ImageList_AddMasked(himl, hbmp, clr); + DeleteObject(hbmp); + hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_DATABASE), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); + m_nDatabase = ImageList_AddMasked(himl, hbmp, clr); + DeleteObject(hbmp); + + if(ImageList_GetImageCount(himl) < 4) + return FALSE ; + + TreeView_SetImageList(m_hControl, himl, TVSIL_NORMAL); + + ShowWindow(m_hControl, SW_SHOW) ; + + return TRUE ; + +} + + + +HTREEITEM CNdbTreeView::AddItem(LPSTR szText, NDB_ITEM_TYPE enType, DWORD dwLVId){ + + TVITEM tvi ; + TVINSERTSTRUCT tvins ; + HTREEITEM hti ; + HTREEITEM hTemp ; + int nImage = m_nClosed ; + + tvi.mask = TVIF_TEXT | TVIF_IMAGE + | TVIF_SELECTEDIMAGE | TVIF_PARAM; + + tvi.pszText = szText; + tvi.cchTextMax = lstrlen(szText); + + switch(enType){ + + case ITEM_COMPR_ROOT: + nImage = m_nClosed ; + if(!m_hPrevRoot) + tvins.hParent = TVI_ROOT; + else + tvins.hInsertAfter = m_hPrevRoot ; + break ; + + case ITEM_DB_ROOT: + if(!m_hPrevRoot) + tvins.hParent = TVI_ROOT; + else + tvins.hInsertAfter = m_hPrevRoot ; + break ; + + case ITEM_COMPR: + nImage = m_nComputer ; + if(!m_hPrevComputersChild || !m_hComputersRoot) + return 0 ; + else + tvins.hInsertAfter = m_hPrevComputersChild ; + tvins.hParent = m_hComputersRoot ; + break ; + + case ITEM_DB: + nImage = m_nDatabase ; + if(!m_hPrevComputersChild || !m_hComputersRoot) + return 0 ; + else + tvins.hInsertAfter = m_hPrevDatabasesChild ; + tvins.hParent = m_hDatabasesRoot ; + break ; + + NDB_DEFAULT_UNREACHABLE ; + + } + + tvi.iImage = nImage ; + tvi.iSelectedImage = nImage ; + tvi.lParam = (LPARAM) dwLVId ; + tvins.item = tvi ; + + hTemp = TreeView_InsertItem(m_hControl, &tvins); + if(!hTemp) + return NULL ; + + switch(enType){ + + case ITEM_COMPR_ROOT: + m_hComputersRoot = hTemp ; + break ; + + case ITEM_DB_ROOT: + m_hDatabasesRoot = hTemp ; + break ; + + case ITEM_COMPR: + m_hPrevComputersChild = hTemp ; + break ; + + case ITEM_DB: + m_hPrevComputersChild = hTemp ; + break ; + + NDB_DEFAULT_UNREACHABLE ; + + } + + if (ITEM_COMPR_ROOT != enType && ITEM_DB_ROOT != enType) { + + hti = TreeView_GetParent(m_hControl, hTemp); + tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvi.hItem = hti; + tvi.iImage = m_nClosed; + tvi.iSelectedImage = m_nClosed; + TreeView_SetItem(m_hControl, &tvi); + + } + + return hTemp ; +} + + +BOOL CNdbControls::Create(HINSTANCE hInst, HWND hParent){ + + m_hInstance = hInst ; + m_hParent = hParent ; + m_tb.Create(m_hInstance, m_hParent, ID_TOOLBAR, IDB_TOOLBAR) ; + m_sb.Create(m_hInstance, m_hParent, ID_STATUSBAR) ; + m_tv.Create(m_hInstance, m_hParent, IDM_TREEVIEW, ID_TREEVIEW) ; + _assert(AddView("Computers", ITEM_COMPR_ROOT)) ; + _assert(AddView("Databases", ITEM_DB_ROOT)) ; + + return TRUE ; +} + +BOOL CNdbControls::AddListView(NDB_ITEM_TYPE enType, DWORD dwId){ + + int count ; + CNdbListView* plv ; + PNDB_LV pst ; + + plv = new CNdbListView ; + + if(!plv) + return FALSE ; + + count = m_map_lvc.GetCount() + m_dwFirstId_lv ; + + switch(enType){ + case ITEM_COMPR_ROOT: + pst = &m_stlvcRoot ; + break ; + case ITEM_DB_ROOT: + pst = &m_stlvdRoot ; + break ; + case ITEM_COMPR: + pst = &m_stlvc ; + break ; + case ITEM_DB: + pst = &m_stlvd ; + break ; + NDB_DEFAULT_UNREACHABLE ; + } + + plv->Create(m_hInstance, m_hParent, dwId, enType, pst, LV_HEADER_WIDTH) ; + + m_map_lvc[count] = plv ; + + return TRUE ; +} + +BOOL CNdbControls::AddView(LPSTR szText, NDB_ITEM_TYPE enType){ + + DWORD dwId_lv = m_dwNextId_lv ; + + if(AddListView(enType, dwId_lv) && m_tv.AddItem(szText, enType, dwId_lv)) + m_dwNextId_lv++ ; + else + return FALSE ; + + return TRUE ; +}; + + +VOID CNdbControls::ToggleListViews(LPNMTREEVIEW pnmtv){ + + CNdbListView* plv ; + int count = m_map_lvc.GetCount() + m_dwFirstId_lv ; + + for(int c = FIRST_ID_LV ; c < count; ++c){ + _assert(m_map_lvc.Lookup(c, plv)) ; + if(pnmtv->itemNew.lParam == (c)) + plv->Show(TRUE) ; + else + plv->Show(FALSE) ; + } +} + + + +VOID CNdbControls::Resize(){ + + RECT rc, rcTB, rcSB ; + LONG tw, sw, lx, ly, lw, lh, tvw, tvh ; + CNdbListView* plv ; + int count ; //, id ; + + GetClientRect(m_hParent, &rc) ; + m_tb.GetRect(&rcTB) ; + m_sb.GetRect(&rcSB) ; + + sw = rcSB.bottom ; + tw = rcTB.bottom ; + + m_tb.Resize(0, 0, rc.right, tw) ; + + tvw = rc.right / 4 ; + tvh = rc.bottom - sw - tw - BORDER ; + + m_tv.Resize(0, tw + BORDER, tvw, tvh) ; + + m_sb.Resize(0, tvh, rc.left, sw) ; + + lx = tvw + BORDER - 2 ; + ly = tw + BORDER ; + lw = rc.right - tvw - BORDER + 1 ; + lh = tvh ; + + count = m_map_lvc.GetCount() + FIRST_ID_LV ; + + for(int c = FIRST_ID_LV ; c < count; ++c){ + _assert(m_map_lvc.Lookup(c, plv)) ; + plv->Resize(lx, ly, lw, lh) ; + } + + return ; + +} diff --git a/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO b/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO Binary files differnew file mode 100644 index 00000000000..ab7b05d9df7 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp new file mode 100644 index 00000000000..2515c6f1b54 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp @@ -0,0 +1,23 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +// stdafx.cpp : source file that includes just the standard includes +// CPC_GUI.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h new file mode 100644 index 00000000000..830735d4c09 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) +#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#ifdef _DEBUG +#define NDB_DEFAULT_UNREACHABLE default: _ASSERT(0); break +#elif _MSC_VER >= 1200 +#define NDB_DEFAULT_UNREACHABLE default: __assume(0); break +#else +#define NDB_DEFAULT_UNREACHABLE default: break +#endif; + + +#ifdef _DEBUG +#define _assert _ASSERT +#else +#define _assert(expr) expr +#endif + + +#include <afx.h> +#include <afxtempl.h> + +// C RunTime Header Files +#include <ndb_global.h> +#include <memory.h> +#include <tchar.h> +#include <commctrl.h> +#include <shlwapi.h> +#include <crtdbg.h> + +// Local Header Files +#include "resource.h" +#include "NdbControls.h" +#include "CPC_GUI.h" + + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp new file mode 100644 index 00000000000..28cd75550c8 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp @@ -0,0 +1,18 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "StdAfx.h" +#include "resource.h" +#include "CPC_GUI.h" diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h new file mode 100644 index 00000000000..6e87f3819de --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h @@ -0,0 +1,18 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + + + diff --git a/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp b/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp Binary files differnew file mode 100644 index 00000000000..e50af403eda --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp diff --git a/storage/ndb/src/cw/cpcc-win32/C++/resource.h b/storage/ndb/src/cw/cpcc-win32/C++/resource.h new file mode 100644 index 00000000000..9bcd7d53b6f --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/resource.h @@ -0,0 +1,89 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by CPC_GUI.rc +// +#define IDC_MYICON 2 +#define IDD_CPC_GUI_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDS_APP_TITLE 103 +#define IDM_ABOUT 104 +#define IDS_LV_ROOT_COMPUTERS 104 +#define IDS_TV_ROOT_COMPUTERS 104 +#define IDM_EXIT 105 +#define IDS_LV_ROOT_DATABASES 105 +#define IDS_TV_ROOT_DATABASES 105 +#define IDS_HELLO 106 +#define IDS_LV_COMPUTER_HEADER_1 106 +#define IDI_CPC_GUI 107 +#define IDS_LV_COMPUTER_HEADER_2 107 +#define IDI_SMALL 108 +#define IDS_LV_PROCESS_HEADER_1 108 +#define IDC_CPC_GUI 109 +#define IDM_CPC_GUI 109 +#define IDS_TIP_NEW 110 +#define IDS_TIP_DELETE 111 +#define IDS_TIP_PROPS 112 +#define IDS_LV_PROCESS_HEADER_2 113 +#define IDS_LV_PROCESS_HEADER_3 114 +#define IDS_LV_PROCESS_HEADER_4 115 +#define IDS_LV_COMPUTER_HEADER_3 116 +#define IDR_MAINFRAME 128 +#define ID_TREEVIEW 130 +#define IDM_TREEVIEW 130 +#define IDB_TOOLBAR 137 +#define ID_TOOLBAR 158 +#define IDB_COMPUTER 168 +#define IDB_CLOSED 169 +#define IDB_OPEN 170 +#define IDI_DATABASE 172 +#define IDI_CLOSED 175 +#define IDI_OPEN 176 +#define IDI_COMPUTER 177 +#define IDB_MASK 178 +#define IDB_DATABASE 182 +#define IDM_TV 183 +#define ID_TREEVIEW1 32771 +#define ID_BUTTON32773 32773 +#define IDM_NEW 32774 +#define IDM_DELETE 32775 +#define IDM_PROPS 32776 +#define ID_LIST_C 32777 +#define ID_ACTIONS_INSERT 32778 +#define ID_ACTIONS_DELETE 32779 +#define ID_DELETE 32780 +#define ID_PROPERTIES 32781 +#define ID_ACTIONS_PROPERTIES 32782 +#define ID_BUTTON32783 32783 +#define ID_BUTTON32784 32784 +#define ID_LIST_P 32785 +#define ID_STATUSBAR 32786 +#define ID_LIST_C_ROOT 32787 +#define ID_LIST_D_ROOT 32788 +#define IDM_ADDNEW 32793 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 184 +#define _APS_NEXT_COMMAND_VALUE 32796 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/storage/ndb/src/cw/cpcc-win32/C++/small.ico b/storage/ndb/src/cw/cpcc-win32/C++/small.ico Binary files differnew file mode 100644 index 00000000000..8f94d9aa828 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/small.ico diff --git a/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp b/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp Binary files differnew file mode 100644 index 00000000000..a1059352c66 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/App.ico b/storage/ndb/src/cw/cpcc-win32/csharp/App.ico Binary files differnew file mode 100644 index 00000000000..3a5525fd794 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/App.ico diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs new file mode 100644 index 00000000000..b19875b97ef --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs @@ -0,0 +1,1415 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Threading; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for Form1. + /// </summary> + public class CPC : System.Windows.Forms.Form + { + private System.Windows.Forms.TreeView tvComputerCluster; + private System.Windows.Forms.ContextMenu ctxTreeViewMenu; + private System.Windows.Forms.ColumnHeader chComputer; + private System.Windows.Forms.ColumnHeader chProcessName; + private System.Windows.Forms.ContextMenu ctxListViewMenu; + private System.Windows.Forms.MenuItem mainMenuItem; + private System.Windows.Forms.ColumnHeader chProcesses; + private System.Windows.Forms.MainMenu mainMenu; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.MenuItem menuItem7; + private System.Windows.Forms.MenuItem menuItem10; + private System.Windows.Forms.MenuItem mainMenuFile; + private System.Windows.Forms.MenuItem mainMenuComputer; + private System.Windows.Forms.MenuItem subMenuComputerAdd; + private System.Windows.Forms.MenuItem subMenuComputerRemove; + private System.Windows.Forms.MenuItem subMenuComputerDisconnect; + private System.Windows.Forms.MenuItem subMenuComputerProperties; + private System.ComponentModel.IContainer components; + + private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MenuItem computerMenuAdd; + private System.Windows.Forms.MenuItem computerMenuRemove; + private System.Windows.Forms.MenuItem menuItem5; + private System.Windows.Forms.MenuItem computerMenuDisconnect; + private System.Windows.Forms.MenuItem computerMenuConnect; + private System.Windows.Forms.MenuItem computerMenuProperties; + private System.Windows.Forms.MenuItem menuItem11; + private System.Windows.Forms.MenuItem tvCtxMenuComputerAdd; + private System.Windows.Forms.MenuItem tvCtxMenuComputerRemove; + private System.Windows.Forms.MenuItem tvCtxMenuComputerConnect; + private System.Windows.Forms.MenuItem tvCtxMenuComputerDisconnect; + private System.Windows.Forms.MenuItem tvCtxMenuComputerDefine; + private System.Windows.Forms.MenuItem tvCtxMenuDatabaseNew; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.MenuItem menuItem2; + private System.Windows.Forms.MenuItem mainMenuDatabase; + private System.Windows.Forms.MenuItem subMenuDatabaseCreate; + private System.Windows.Forms.MenuItem menuItem8; + private System.Windows.Forms.MenuItem tvCtxMenuProperties; + private System.Windows.Forms.ImageList imageTV; + + private ComputerMgmt computerMgmt; + private System.Windows.Forms.MenuItem computerMenuRefresh; + private System.Windows.Forms.ListView listView; + private System.Windows.Forms.ColumnHeader chComputerIP; + private System.Windows.Forms.ColumnHeader chDatabase; + private System.Windows.Forms.ColumnHeader chName; + private System.Windows.Forms.ColumnHeader chOwner; + private System.Windows.Forms.ColumnHeader chStatus; + private System.Windows.Forms.Splitter splitter2; + private System.Windows.Forms.Splitter splitterVertical; + private System.Windows.Forms.Splitter splitterHorizont; + private Thread guiThread; + private float resizeWidthRatio; + private System.Windows.Forms.MenuItem menuItem6; + private System.Windows.Forms.MenuItem menuGetStatus; + private System.Windows.Forms.MenuItem menuStartProcess; + private System.Windows.Forms.MenuItem menuRestartProcess; + private System.Windows.Forms.MenuItem menuStopProcess; + private System.Windows.Forms.MenuItem menuRemoveProcess; + private System.Windows.Forms.MenuItem menuRefresh; + private System.Windows.Forms.OpenFileDialog openHostFileDialog; + private System.Windows.Forms.SaveFileDialog saveHostFileDialog; + private float resizeHeightRatio; + private System.Windows.Forms.TextBox mgmConsole; + int i; + public CPC() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // TODO: Add any constructor code after InitializeComponent call + // + computerMgmt = new ComputerMgmt(); + guiThread = new Thread(new ThreadStart(updateGuiThread)); + + // guiThread.Start(); + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + //guiThread.Abort(); + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CPC)); + this.tvComputerCluster = new System.Windows.Forms.TreeView(); + this.ctxTreeViewMenu = new System.Windows.Forms.ContextMenu(); + this.tvCtxMenuComputerAdd = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuComputerRemove = new System.Windows.Forms.MenuItem(); + this.menuGetStatus = new System.Windows.Forms.MenuItem(); + this.menuItem6 = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuComputerConnect = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuComputerDisconnect = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuDatabaseNew = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuComputerDefine = new System.Windows.Forms.MenuItem(); + this.menuItem8 = new System.Windows.Forms.MenuItem(); + this.tvCtxMenuProperties = new System.Windows.Forms.MenuItem(); + this.imageTV = new System.Windows.Forms.ImageList(this.components); + this.ctxListViewMenu = new System.Windows.Forms.ContextMenu(); + this.menuStartProcess = new System.Windows.Forms.MenuItem(); + this.menuRestartProcess = new System.Windows.Forms.MenuItem(); + this.menuStopProcess = new System.Windows.Forms.MenuItem(); + this.menuRemoveProcess = new System.Windows.Forms.MenuItem(); + this.menuRefresh = new System.Windows.Forms.MenuItem(); + this.computerMenuAdd = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.computerMenuRemove = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.computerMenuDisconnect = new System.Windows.Forms.MenuItem(); + this.computerMenuConnect = new System.Windows.Forms.MenuItem(); + this.menuItem11 = new System.Windows.Forms.MenuItem(); + this.computerMenuProperties = new System.Windows.Forms.MenuItem(); + this.computerMenuRefresh = new System.Windows.Forms.MenuItem(); + this.chComputer = new System.Windows.Forms.ColumnHeader(); + this.chProcessName = new System.Windows.Forms.ColumnHeader(); + this.mainMenuItem = new System.Windows.Forms.MenuItem(); + this.chProcesses = new System.Windows.Forms.ColumnHeader(); + this.mainMenu = new System.Windows.Forms.MainMenu(); + this.mainMenuFile = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.mainMenuComputer = new System.Windows.Forms.MenuItem(); + this.subMenuComputerAdd = new System.Windows.Forms.MenuItem(); + this.menuItem7 = new System.Windows.Forms.MenuItem(); + this.subMenuComputerDisconnect = new System.Windows.Forms.MenuItem(); + this.subMenuComputerRemove = new System.Windows.Forms.MenuItem(); + this.menuItem10 = new System.Windows.Forms.MenuItem(); + this.subMenuComputerProperties = new System.Windows.Forms.MenuItem(); + this.mainMenuDatabase = new System.Windows.Forms.MenuItem(); + this.subMenuDatabaseCreate = new System.Windows.Forms.MenuItem(); + this.panel1 = new System.Windows.Forms.Panel(); + this.mgmConsole = new System.Windows.Forms.TextBox(); + this.splitterHorizont = new System.Windows.Forms.Splitter(); + this.splitter2 = new System.Windows.Forms.Splitter(); + this.listView = new System.Windows.Forms.ListView(); + this.chComputerIP = new System.Windows.Forms.ColumnHeader(); + this.chStatus = new System.Windows.Forms.ColumnHeader(); + this.chDatabase = new System.Windows.Forms.ColumnHeader(); + this.chName = new System.Windows.Forms.ColumnHeader(); + this.chOwner = new System.Windows.Forms.ColumnHeader(); + this.splitterVertical = new System.Windows.Forms.Splitter(); + this.openHostFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveHostFileDialog = new System.Windows.Forms.SaveFileDialog(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // tvComputerCluster + // + this.tvComputerCluster.CausesValidation = false; + this.tvComputerCluster.ContextMenu = this.ctxTreeViewMenu; + this.tvComputerCluster.Dock = System.Windows.Forms.DockStyle.Left; + this.tvComputerCluster.ImageList = this.imageTV; + this.tvComputerCluster.Name = "tvComputerCluster"; + this.tvComputerCluster.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { + new System.Windows.Forms.TreeNode("Computer", 0, 0), + new System.Windows.Forms.TreeNode("Database", 5, 5)}); + this.tvComputerCluster.Size = new System.Drawing.Size(104, 333); + this.tvComputerCluster.TabIndex = 5; + this.tvComputerCluster.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvComputerCluster_MouseDown); + this.tvComputerCluster.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvComputerCluster_AfterSelect); + this.tvComputerCluster.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeCollapse); + this.tvComputerCluster.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeExpand); + // + // ctxTreeViewMenu + // + this.ctxTreeViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.tvCtxMenuComputerAdd, + this.tvCtxMenuComputerRemove, + this.menuGetStatus, + this.menuItem6, + this.tvCtxMenuComputerConnect, + this.tvCtxMenuComputerDisconnect, + this.tvCtxMenuDatabaseNew, + this.tvCtxMenuComputerDefine, + this.menuItem8, + this.tvCtxMenuProperties}); + this.ctxTreeViewMenu.Popup += new System.EventHandler(this.ctxTreeViewMenu_Popup); + // + // tvCtxMenuComputerAdd + // + this.tvCtxMenuComputerAdd.Index = 0; + this.tvCtxMenuComputerAdd.Text = "Add computer"; + this.tvCtxMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click); + // + // tvCtxMenuComputerRemove + // + this.tvCtxMenuComputerRemove.Index = 1; + this.tvCtxMenuComputerRemove.Text = "Remove computer"; + this.tvCtxMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click); + // + // menuGetStatus + // + this.menuGetStatus.Index = 2; + this.menuGetStatus.Text = "Get Status"; + this.menuGetStatus.Click += new System.EventHandler(this.menuGetStatus_Click); + // + // menuItem6 + // + this.menuItem6.Index = 3; + this.menuItem6.Text = "-"; + // + // tvCtxMenuComputerConnect + // + this.tvCtxMenuComputerConnect.Index = 4; + this.tvCtxMenuComputerConnect.Text = "Connect"; + // + // tvCtxMenuComputerDisconnect + // + this.tvCtxMenuComputerDisconnect.Index = 5; + this.tvCtxMenuComputerDisconnect.Text = "Disconnect"; + // + // tvCtxMenuDatabaseNew + // + this.tvCtxMenuDatabaseNew.Index = 6; + this.tvCtxMenuDatabaseNew.Text = "Create database..."; + this.tvCtxMenuDatabaseNew.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click); + // + // tvCtxMenuComputerDefine + // + this.tvCtxMenuComputerDefine.Index = 7; + this.tvCtxMenuComputerDefine.Text = "Define process..."; + this.tvCtxMenuComputerDefine.Click += new System.EventHandler(this.tvCtxMenuComputerDefine_Click); + // + // menuItem8 + // + this.menuItem8.Index = 8; + this.menuItem8.Text = "-"; + // + // tvCtxMenuProperties + // + this.tvCtxMenuProperties.Index = 9; + this.tvCtxMenuProperties.Text = "Properties"; + // + // imageTV + // + this.imageTV.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; + this.imageTV.ImageSize = new System.Drawing.Size(16, 16); + this.imageTV.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageTV.ImageStream"))); + this.imageTV.TransparentColor = System.Drawing.Color.Transparent; + // + // ctxListViewMenu + // + this.ctxListViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuStartProcess, + this.menuRestartProcess, + this.menuStopProcess, + this.menuRemoveProcess, + this.menuRefresh}); + this.ctxListViewMenu.Popup += new System.EventHandler(this.ctxListViewMenu_Popup); + // + // menuStartProcess + // + this.menuStartProcess.Index = 0; + this.menuStartProcess.Text = "Start process"; + this.menuStartProcess.Click += new System.EventHandler(this.startProcess); + // + // menuRestartProcess + // + this.menuRestartProcess.Index = 1; + this.menuRestartProcess.Text = "Restart process"; + this.menuRestartProcess.Click += new System.EventHandler(this.restartProcess); + // + // menuStopProcess + // + this.menuStopProcess.Index = 2; + this.menuStopProcess.Text = "Stop process"; + this.menuStopProcess.Click += new System.EventHandler(this.stopProcess); + // + // menuRemoveProcess + // + this.menuRemoveProcess.Index = 3; + this.menuRemoveProcess.Text = "Remove process"; + this.menuRemoveProcess.Click += new System.EventHandler(this.removeProcess); + // + // menuRefresh + // + this.menuRefresh.Index = 4; + this.menuRefresh.Text = "Refresh"; + this.menuRefresh.Click += new System.EventHandler(this.menuRefresh_Click); + // + // computerMenuAdd + // + this.computerMenuAdd.Index = -1; + this.computerMenuAdd.Text = "Add"; + this.computerMenuAdd.Click += new System.EventHandler(this.computerMenuAdd_Click); + // + // menuItem3 + // + this.menuItem3.Index = -1; + this.menuItem3.Text = "-"; + // + // computerMenuRemove + // + this.computerMenuRemove.Index = -1; + this.computerMenuRemove.Text = "Remove"; + this.computerMenuRemove.Click += new System.EventHandler(this.computerMenuRemove_Click); + // + // menuItem5 + // + this.menuItem5.Index = -1; + this.menuItem5.Text = "-"; + // + // computerMenuDisconnect + // + this.computerMenuDisconnect.Index = -1; + this.computerMenuDisconnect.Text = "Disconnect"; + // + // computerMenuConnect + // + this.computerMenuConnect.Index = -1; + this.computerMenuConnect.Text = "Connect"; + // + // menuItem11 + // + this.menuItem11.Index = -1; + this.menuItem11.Text = "-"; + // + // computerMenuProperties + // + this.computerMenuProperties.Index = -1; + this.computerMenuProperties.Text = "Properties"; + // + // computerMenuRefresh + // + this.computerMenuRefresh.Index = -1; + this.computerMenuRefresh.Text = "Refresh"; + this.computerMenuRefresh.Click += new System.EventHandler(this.computerMenuRefresh_Click); + // + // chComputer + // + this.chComputer.Text = "Computer"; + // + // chProcessName + // + this.chProcessName.Text = "Name"; + // + // mainMenuItem + // + this.mainMenuItem.Index = -1; + this.mainMenuItem.Text = "File"; + // + // chProcesses + // + this.chProcesses.Text = "Id"; + // + // mainMenu + // + this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.mainMenuFile, + this.mainMenuComputer, + this.mainMenuDatabase}); + // + // mainMenuFile + // + this.mainMenuFile.Index = 0; + this.mainMenuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem2, + this.menuItem1}); + this.mainMenuFile.Text = "&File"; + // + // menuItem2 + // + this.menuItem2.Index = 0; + this.menuItem2.Text = "&Import..."; + this.menuItem2.Click += new System.EventHandler(this.importHostFile); + // + // menuItem1 + // + this.menuItem1.Index = 1; + this.menuItem1.Text = "&Export..."; + this.menuItem1.Click += new System.EventHandler(this.exportHostFile); + // + // mainMenuComputer + // + this.mainMenuComputer.Index = 1; + this.mainMenuComputer.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.subMenuComputerAdd, + this.menuItem7, + this.subMenuComputerDisconnect, + this.subMenuComputerRemove, + this.menuItem10, + this.subMenuComputerProperties}); + this.mainMenuComputer.Text = "&Computer"; + // + // subMenuComputerAdd + // + this.subMenuComputerAdd.Index = 0; + this.subMenuComputerAdd.Text = "&Add Computer"; + this.subMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click); + // + // menuItem7 + // + this.menuItem7.Index = 1; + this.menuItem7.Text = "-"; + // + // subMenuComputerDisconnect + // + this.subMenuComputerDisconnect.Index = 2; + this.subMenuComputerDisconnect.Text = "&Disconnect"; + // + // subMenuComputerRemove + // + this.subMenuComputerRemove.Index = 3; + this.subMenuComputerRemove.Text = "&Remove Computer"; + this.subMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click); + // + // menuItem10 + // + this.menuItem10.Index = 4; + this.menuItem10.Text = "-"; + // + // subMenuComputerProperties + // + this.subMenuComputerProperties.Index = 5; + this.subMenuComputerProperties.Text = "&Properties"; + // + // mainMenuDatabase + // + this.mainMenuDatabase.Index = 2; + this.mainMenuDatabase.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.subMenuDatabaseCreate}); + this.mainMenuDatabase.Text = "&Database"; + this.mainMenuDatabase.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click); + // + // subMenuDatabaseCreate + // + this.subMenuDatabaseCreate.Index = 0; + this.subMenuDatabaseCreate.Text = "&Create database..."; + this.subMenuDatabaseCreate.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click); + // + // panel1 + // + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] { + this.mgmConsole, + this.splitterHorizont, + this.splitter2, + this.listView}); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(104, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(384, 333); + this.panel1.TabIndex = 6; + // + // mgmConsole + // + this.mgmConsole.AccessibleRole = System.Windows.Forms.AccessibleRole.StaticText; + this.mgmConsole.Dock = System.Windows.Forms.DockStyle.Bottom; + this.mgmConsole.Location = new System.Drawing.Point(0, 231); + this.mgmConsole.Multiline = true; + this.mgmConsole.Name = "mgmConsole"; + this.mgmConsole.Size = new System.Drawing.Size(384, 96); + this.mgmConsole.TabIndex = 5; + this.mgmConsole.Text = "textBox1"; + this.mgmConsole.TextChanged += new System.EventHandler(this.mgmConsole_TextChanged); + this.mgmConsole.Enter += new System.EventHandler(this.mgmConsole_Enter); + // + // splitterHorizont + // + this.splitterHorizont.Dock = System.Windows.Forms.DockStyle.Bottom; + this.splitterHorizont.Location = new System.Drawing.Point(0, 327); + this.splitterHorizont.MinExtra = 100; + this.splitterHorizont.MinSize = 100; + this.splitterHorizont.Name = "splitterHorizont"; + this.splitterHorizont.Size = new System.Drawing.Size(384, 3); + this.splitterHorizont.TabIndex = 4; + this.splitterHorizont.TabStop = false; + // + // splitter2 + // + this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.splitter2.Location = new System.Drawing.Point(0, 330); + this.splitter2.Name = "splitter2"; + this.splitter2.Size = new System.Drawing.Size(384, 3); + this.splitter2.TabIndex = 2; + this.splitter2.TabStop = false; + // + // listView + // + this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chComputerIP, + this.chStatus, + this.chDatabase, + this.chName, + this.chOwner}); + this.listView.ContextMenu = this.ctxListViewMenu; + this.listView.Dock = System.Windows.Forms.DockStyle.Fill; + this.listView.FullRowSelect = true; + this.listView.Name = "listView"; + this.listView.Size = new System.Drawing.Size(384, 333); + this.listView.TabIndex = 0; + this.listView.View = System.Windows.Forms.View.Details; + this.listView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView_ColumnClick_1); + this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged); + // + // chComputerIP + // + this.chComputerIP.Text = "IP Adress"; + // + // chStatus + // + this.chStatus.Text = "Status"; + // + // chDatabase + // + this.chDatabase.Text = "Database"; + // + // chName + // + this.chName.Text = "Name"; + // + // chOwner + // + this.chOwner.Text = "Owner"; + // + // splitterVertical + // + this.splitterVertical.Location = new System.Drawing.Point(104, 0); + this.splitterVertical.MinSize = 100; + this.splitterVertical.Name = "splitterVertical"; + this.splitterVertical.Size = new System.Drawing.Size(3, 333); + this.splitterVertical.TabIndex = 7; + this.splitterVertical.TabStop = false; + this.splitterVertical.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitterVertical_SplitterMoved); + // + // openHostFileDialog + // + this.openHostFileDialog.DefaultExt = "cpc"; + this.openHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*"; + this.openHostFileDialog.Title = "Import a CPCd configuration file"; + this.openHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openHostFileDialog_FileOk); + // + // saveHostFileDialog + // + this.saveHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*"; + this.saveHostFileDialog.Title = "Export a CPCd configuration file"; + this.saveHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.saveHostFileDialog_FileOk); + // + // CPC + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(488, 333); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.splitterVertical, + this.panel1, + this.tvComputerCluster}); + this.Menu = this.mainMenu; + this.Name = "CPC"; + this.Text = "CPC"; + this.Resize += new System.EventHandler(this.CPC_Resize); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CPC_MouseDown); + this.Closing += new System.ComponentModel.CancelEventHandler(this.CPC_Closing); + this.Load += new System.EventHandler(this.CPC_Load); + this.Activated += new System.EventHandler(this.CPC_Activated); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.CPC_Paint); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main() + { + Application.Run(new CPC()); + + } + + private void tvComputerCluster_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) + { + if(e.Node.Text.ToString().Equals("Database")) + { + updateListViews("Database"); + + return; + } + if(e.Node.Text.ToString().Equals("Computer")) + { + //updateListViews(); + + updateListViews("Computer"); + return; + } + if(e.Node.Parent.Text.ToString().Equals("Database")) + { + //updateListViews(); + listView.Columns.Clear(); + listView.Columns.Add(this.chName); + listView.Columns.Add(this.chDatabase); + listView.Columns.Add(this.chStatus); + listView.Columns.Add(this.chOwner); + updateDatabaseView(e.Node.Text.ToString()); + } + + if(e.Node.Parent.Text=="Computer") + { + //updateListViews(); + + Computer c=computerMgmt.getComputer(e.Node.Text.ToString()); + string [] processcols= new string[5]; + ArrayList processes; + processes = c.getProcesses(); + listView.Items.Clear(); + listView.Columns.Clear(); + listView.Columns.Add(this.chComputer); + listView.Columns.Add(this.chDatabase); + listView.Columns.Add(this.chName); + listView.Columns.Add(this.chStatus); + listView.Columns.Add(this.chOwner); + if(processes != null ) + { + + listView.BeginUpdate(); + foreach(Process p in processes) + { + processcols[0]=p.getComputer().getName(); + processcols[1]=p.getDatabase(); + processcols[2]=p.getName(); + processcols[3]=p.getStatusString(); + processcols[4]=p.getOwner(); + ListViewItem lvp= new ListViewItem(processcols); + listView.Items.Add(lvp); + } + + listView.EndUpdate(); + } + + + listView.Show(); + } + + } + + + + private void ctxTreeViewMenu_Popup(object sender, System.EventArgs e) + { + tvCtxMenuComputerAdd.Enabled=true; + tvCtxMenuComputerRemove.Enabled=true; + tvCtxMenuComputerConnect.Enabled=true; + tvCtxMenuComputerDisconnect.Enabled=true; + tvCtxMenuComputerDefine.Enabled=true; + menuGetStatus.Enabled=true; + tvCtxMenuDatabaseNew.Enabled=true; + tvCtxMenuComputerAdd.Visible=true; + tvCtxMenuComputerRemove.Visible=true; + tvCtxMenuComputerConnect.Visible=true; + tvCtxMenuComputerDisconnect.Visible=true; + tvCtxMenuComputerDefine.Visible=true; + tvCtxMenuDatabaseNew.Visible=true; + tvCtxMenuProperties.Visible=true; + menuGetStatus.Visible=true; + + if(tvComputerCluster.SelectedNode.Text.Equals("Computer")) + { + tvCtxMenuComputerAdd.Enabled=true; + tvCtxMenuComputerRemove.Enabled=false; + tvCtxMenuComputerConnect.Enabled=false; + tvCtxMenuComputerDisconnect.Enabled=false; + tvCtxMenuComputerDefine.Enabled=false; + tvCtxMenuDatabaseNew.Visible=false; + menuGetStatus.Visible=false; + return; + } + + if(tvComputerCluster.SelectedNode.Text.Equals("Database")) + { + // ctxTreeViewMenu.MenuItems.Add(menuDatabaseItem1); + tvCtxMenuComputerAdd.Visible=false; + tvCtxMenuComputerRemove.Visible=false; + tvCtxMenuComputerConnect.Visible=false; + tvCtxMenuComputerDisconnect.Visible=false; + tvCtxMenuComputerDefine.Visible=false; + tvCtxMenuDatabaseNew.Visible=true; + tvCtxMenuDatabaseNew.Enabled=true; + menuGetStatus.Visible=false; + menuItem6.Visible=false; + return; + } + if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Computer")) + { + + Computer c= computerMgmt.getComputer(tvComputerCluster.SelectedNode.Text.ToString()); + if(c.getStatus().Equals(Computer.Status.Disconnected)) + { + tvCtxMenuComputerConnect.Enabled=true; + tvCtxMenuComputerDisconnect.Enabled=false; + } + else + { + tvCtxMenuComputerDisconnect.Enabled=true; + tvCtxMenuComputerConnect.Enabled=false; + } + + tvCtxMenuComputerAdd.Enabled=false; + tvCtxMenuComputerRemove.Enabled=true; + menuGetStatus.Visible=false; + + tvCtxMenuComputerDefine.Enabled=true; + tvCtxMenuDatabaseNew.Visible=false; + return; + } + + if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Database")) + { + tvCtxMenuComputerAdd.Enabled=true; + tvCtxMenuComputerRemove.Enabled=false; + tvCtxMenuComputerConnect.Enabled=false; + tvCtxMenuComputerDisconnect.Enabled=false; + tvCtxMenuComputerDefine.Enabled=false; + tvCtxMenuDatabaseNew.Visible=true; + menuGetStatus.Visible=true; + return; + } + + + } + + + private void listView_SelectedIndexChanged(object sender, System.EventArgs e) + { + //MessageBox.Show(listView.SelectedItems[0].Text); + } + + + private void tvComputerCluster_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) + { /* + TreeNode node = tvComputerCluster.GetNodeAt(e.X,e.Y); + if(node==null) + { + return; + } + tvComputerCluster.SelectedNode=node; +// updateListViews(); + tvComputerCluster.SelectedNode.Expand(); + */ + } + + + private void subMenuComputerRemove_Click(object sender, System.EventArgs e) + { + //ComputerRemoveDialog crd=new ComputerRemoveDialog(computerMgmt); + //crd.Show(); + //updateListViews(); +/* string computer = tvComputerCluster.SelectedNode.Text.ToString(); + if(MessageBox.Show(this,"Are you sure you want to remove: " +computer+ "?","Remove computer",MessageBoxButtons.YesNo)==DialogResult.Yes) + { + computerMgmt.RemoveComputer(computer); + } +*/ + } + + private void subMenuComputerAdd_Click(object sender, System.EventArgs e) + { + ComputerAddDialog cad=new ComputerAddDialog(computerMgmt); + cad.ShowDialog(); + cad.Dispose(); +/// updateListViews(tvComputerCluster.SelectedNode.Text.ToString()); + } + + + + private void updateListViews(string node) + { + if(node.Equals("Computer")) + { + listView.Columns.Clear(); + listView.Items.Clear(); + ArrayList list= computerMgmt.getComputerCollection(); + string [] computercols= new string[2]; + + + listView.BeginUpdate(); + listView.Columns.Add(this.chComputer); + listView.Columns.Add(this.chStatus); + foreach (Computer computer in list) + { + computercols[0]=computer.getName(); + computercols[1]=computer.getStatusString(); + + ListViewItem lvc= new ListViewItem(computercols); + + listView.Items.Add(lvc); + + } + listView.EndUpdate(); + listView.Show(); + } + + if(node.Equals("Database")) + { + + ArrayList databases= computerMgmt.getDatabaseCollection(); + string [] dbcols= new string[3]; + + + listView.BeginUpdate(); + listView.Items.Clear(); + listView.Columns.Clear(); + listView.Columns.Add(this.chDatabase); + listView.Columns.Add(this.chStatus); + listView.Columns.Add(this.chOwner); + foreach (Database db in databases) + { + dbcols[0]=db.getName(); + dbcols[1]=db.getStatusString(); + dbcols[2]=db.getOwner(); + + ListViewItem lvc= new ListViewItem(dbcols); + + listView.Items.Add(lvc); + + } + listView.EndUpdate(); + + listView.Show(); + } + + } + + public void updateDatabaseView(string database) + { + Database d=computerMgmt.getDatabase(database); + string [] processcols= new string[5]; + ArrayList processes = d.getProcesses(); + listView.Items.Clear(); + if(processes != null ) + { + + listView.BeginUpdate(); + listView.Columns.Clear(); + listView.Columns.Add(this.chComputer); + listView.Columns.Add(this.chDatabase); + listView.Columns.Add(this.chName); + listView.Columns.Add(this.chStatus); + listView.Columns.Add(this.chOwner); + + foreach(Process p in processes) + { + processcols[0]=p.getComputer().getName(); + processcols[1]=p.getDatabase(); + processcols[2]=p.getName(); + processcols[3]=p.getStatusString(); + processcols[4]=p.getOwner(); + ListViewItem lvp= new ListViewItem(processcols); + listView.Items.Add(lvp); + } + + listView.EndUpdate(); + } + + listView.Show(); + } + + private void updateTreeViews() + { + //tvComputerCluster.Nodes.Clear(); + ArrayList computers= computerMgmt.getComputerCollection(); + + ArrayList databases= computerMgmt.getDatabaseCollection(); + + tvComputerCluster.BeginUpdate(); + tvComputerCluster.Nodes[0].Nodes.Clear(); + tvComputerCluster.Nodes[1].Nodes.Clear(); + if(computers != null) + { + foreach (Computer computer in computers) + { + tvComputerCluster.Nodes[0].Nodes.Add(new TreeNode(computer.getName().ToString())); + } + } + if(databases != null) + { + foreach (Database db in databases) + { + tvComputerCluster.Nodes[1].Nodes.Add(new TreeNode(db.getName().ToString())); + } + } + + tvComputerCluster.EndUpdate(); + } + + + private void CPC_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) + { + //updateListViews(); + //updateTreeViews(); + + } + + private void CPC_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + if(tvComputerCluster.SelectedNode!=null) + { + if(tvComputerCluster.SelectedNode.Text.ToString().Equals("Computer")) + updateListViews("Computer"); + } + + //updateListViews(); + //updateTreeViews(); + } + + private void CPC_Activated(object sender, System.EventArgs e) + { + updateListViews(tvComputerCluster.SelectedNode.Text.ToString()); + //updateListViews(); + updateTreeViews(); + } + + + private void computerMenuAdd_Click(object sender, System.EventArgs e) + { + ComputerAddDialog cad=new ComputerAddDialog(computerMgmt); + cad.ShowDialog(); + cad.Dispose(); + + } + + private void computerMenuRemove_Click(object sender, System.EventArgs e) + { + + string computer = tvComputerCluster.SelectedNode.Text.ToString(); + if(MessageBox.Show("Are you sure you want to remove: " + computer +"?\n" + "This will remove all processes on the computer!" ,"Remove selected computer",MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes) + { + removeComputer(computer); + } + } + + private void removeComputer(string computer) + { + ArrayList processes; + Computer c=computerMgmt.getComputer(computer); + processes = c.getProcesses(); + + /*foreach(Process p in processes) + { + removeProcess(computer,p.getName()); + processes=c.getProcesses(); + } +*/ + if(computerMgmt.RemoveComputer(computer)) + { + tvComputerCluster.SelectedNode=tvComputerCluster.SelectedNode.PrevVisibleNode; + this.updateTreeViews(); + this.updateListViews("Computer"); + + if(tvComputerCluster.SelectedNode!=null) + this.updateListViews(tvComputerCluster.SelectedNode.Text.ToString()); + //updateListViews(); + } + } + + private void listView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) + { + + if(listView.Sorting.Equals(SortOrder.Ascending)) + listView.Sorting=SortOrder.Descending; + else + listView.Sorting=SortOrder.Ascending; + + } + + + private void subMenuDatabaseCreate_Click(object sender, System.EventArgs e) + { + PanelWizard p = new PanelWizard(this.computerMgmt); + p.ShowDialog(); + } + + private void tvCtxMenuComputerDefine_Click(object sender, System.EventArgs e) + { + ProcessDefineDialog pdd = new ProcessDefineDialog(this.computerMgmt, + tvComputerCluster.SelectedNode.Text.ToString()); + pdd.Show(); + } + + private void listView_ItemActivate(object sender, System.EventArgs e) + { + updateDatabaseView(listView.SelectedItems[0].Text.ToString()); + for(int i=0;i<tvComputerCluster.Nodes[1].Nodes.Count;i++) + { + if(tvComputerCluster.Nodes[1].Nodes[i].Text.ToString().Equals(listView.SelectedItems[0].Text.ToString())) + { + tvComputerCluster.SelectedNode=tvComputerCluster.Nodes[1].Nodes[i]; + break; + } + } + + + } + + private void CPC_Resize(object sender, System.EventArgs e) + { + if(this.Width < 200) this.Width=200; + if(this.Height <200) this.Height=200; + this.tvComputerCluster.Width=(int)(this.Width*this.resizeWidthRatio); + this.listView.Height=(int)(this.Height*this.resizeHeightRatio); + + //this.Size=new System.Drawing.Size((int)(this.Size.Width*this.tvComputerCluster.Width + + } + + + + private void updateGuiThread() + { + while(true) { + if(tvComputerCluster.SelectedNode!=null) + { + if(tvComputerCluster.SelectedNode.Text.ToString().Equals("Computer")) + updateListViews("Computer"); + } + Thread.Sleep(1000); + } + } + + private void computerMenuRefresh_Click(object sender, System.EventArgs e) + { + updateListViews("Computer"); + } + + private void CPC_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + /*clean up*/ + ArrayList comp = this.computerMgmt.getComputerCollection(); + foreach(Computer c in comp) + { + c.disconnect(); + } + } + + private void CPC_Load(object sender, System.EventArgs e) + { + this.tvComputerCluster.Width=104; + resizeWidthRatio =(float) ((float)(this.tvComputerCluster.Width)/(float)(this.Width)); + resizeHeightRatio = (float) ((float)(this.listView.Height)/(float)(this.Height)); + listView.Columns.Clear(); + listView.Columns.Add(this.chComputer); + listView.Columns.Add(this.chStatus); + + } + + private void splitterVertical_SplitterMoved(object sender, System.Windows.Forms.SplitterEventArgs e) + { + if(this.Width < 500) + this.Width=500; + } + + private void menuGetStatus_Click(object sender, System.EventArgs e) + { + + } + + private void tvComputerCluster_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) + { + if (e.Node.Parent!=null && e.Node.Nodes.Count !=0) + e.Cancel=true; + if(e.Node.IsExpanded) + e.Cancel=true; + } + + private void tvComputerCluster_BeforeCollapse(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) + { + e.Cancel=true; + if (e.Node.Parent!=null && e.Node.Nodes.Count !=0) + e.Cancel=true; + if(e.Node.IsExpanded) + e.Cancel=false; + } + + + + private void ctxListViewMenu_Popup(object sender, System.EventArgs e) + { + + menuStartProcess.Visible=false; + menuStopProcess.Visible=false; + menuRestartProcess.Visible=false; + menuRemoveProcess.Visible=false; + menuRefresh.Visible=false; + + + if(this.tvComputerCluster.SelectedNode.Text.Equals("Computer")) + { + return; + } + + if(this.tvComputerCluster.SelectedNode.Text.Equals("Database")) + { + return; + } + + if(this.tvComputerCluster.SelectedNode.Parent.Text.Equals("Computer")) + { + if(listView.SelectedItems==null) + return; + menuRefresh.Visible=true; + } + if(this.tvComputerCluster.SelectedNode.Parent.Text.Equals("Database")) + { + if(listView.SelectedItems==null) + return; + menuStartProcess.Visible=true; + menuStopProcess.Visible=true; + menuRestartProcess.Visible=true; + menuRemoveProcess.Visible=true; + menuRefresh.Visible=true; + menuStopProcess.Enabled=true; + menuStartProcess.Enabled=true; + menuRestartProcess.Enabled=true; + menuRemoveProcess.Enabled=true; + menuRefresh.Enabled=true; + } + + + computerMenuRemove.Enabled=true; + computerMenuConnect.Enabled=true; + computerMenuDisconnect.Enabled=true; + computerMenuRefresh.Enabled=true; + string selectedItem=""; + if(listView.SelectedItems.Count>0) + selectedItem=listView.FocusedItem.Text.ToString(); + + + if(selectedItem.Equals("")) + { + computerMenuAdd.Enabled=true; + computerMenuRemove.Enabled=false; + computerMenuConnect.Enabled=false; + computerMenuDisconnect.Enabled=false; + return; + } + else + { + computerMenuAdd.Enabled=false; + if(computerMgmt.getStatus(selectedItem).Equals(Computer.Status.Connected)) + { + computerMenuConnect.Enabled=false; + computerMenuRemove.Enabled=true; + } + if(computerMgmt.getStatus(selectedItem).Equals(Computer.Status.Disconnected)) + computerMenuDisconnect.Enabled=false; + } + + + } + + private void startProcess(object sender, System.EventArgs e) + { + if(listView.SelectedItems.Count==0) + return; + + string computer = listView.SelectedItems[0].SubItems[0].Text.ToString(); + string process = listView.SelectedItems[0].SubItems[2].Text.ToString(); + + if(computerMgmt.getComputer(computer).getProcessByName(process).getStatus()==Process.Status.Running) + { + MessageBox.Show(this,"The process is already started!" ,"Process failed to start",MessageBoxButtons.OK); + return; + } + + int status = startProcess(listView.SelectedItems[0].SubItems[0].Text.ToString(),listView.SelectedItems[0].SubItems[2].Text.ToString()); + + + if(status < 0) + MessageBox.Show(this,"Either the link is not OK, or the process is misconfigured! Status : " + status,"Process failed to start",MessageBoxButtons.OK); + else + MessageBox.Show(this,"The process was sucessfully started!","Process started",MessageBoxButtons.OK); + + } + + private int startProcess(string computer, string process) + { + Computer c=computerMgmt.getComputer(computer); + int status = c.startProcess(c.getProcessByName(process)); + return status; + } + + private void listView_ColumnClick_1(object sender, System.Windows.Forms.ColumnClickEventArgs e) + { + // if(listView.Columns[e.Column].Text.Equals("Computer")) + // { + if(listView.Sorting.Equals(SortOrder.Ascending)) + { + listView.Sorting=SortOrder.Descending; + } + else + { + listView.Sorting=SortOrder.Ascending; + } + // } + } + + private void removeProcess(object sender, System.EventArgs e) + { + if(listView.SelectedItems.Count==0) + return; + string process = listView.SelectedItems[0].SubItems[2].Text.ToString(); + string computer = listView.SelectedItems[0].SubItems[0].Text.ToString(); + + if(MessageBox.Show("Are you sure that you want to remove " + process + " permanently?","Remove process",MessageBoxButtons.YesNo) == DialogResult.No) + return; + removeProcess(computer,process); + MessageBox.Show(this,"The process was sucessfully removed!","Remove process",MessageBoxButtons.OK); + } + + private void removeProcess(string computer, string process) + { + + Computer c=computerMgmt.getComputer(computer); + stopProcess(computer,process); + int status = c.undefineProcess(c.getProcessByName(process)); + //if(status < 0) + // MessageBox.Show(this,"The process could not be removed!","Failed to remove process",MessageBoxButtons.OK); + // else + // { + Database db = computerMgmt.getDatabase((c.getProcessByName(process).getDatabase())); + db.removeProcess(process); + c.removeProcess(process,db.getName()); + updateListViews("Database"); + // } + } + + private void stopProcess(object sender, System.EventArgs e) + { + if(listView.SelectedItems.Count==0) + return; + string computer = listView.SelectedItems[0].SubItems[0].Text.ToString(); + string process = listView.SelectedItems[0].SubItems[2].Text.ToString(); + if(computerMgmt.getComputer(computer).getProcessByName(process).getStatus()==Process.Status.Stopped) + { + MessageBox.Show(this,"The process is already stopped!" ,"Process failed to stop",MessageBoxButtons.OK); + return; + } + + if(DialogResult.No==MessageBox.Show(this,"Are you sure you want to stop the " + process + " process?","Stop process!", MessageBoxButtons.YesNo)) + return; + + int status = stopProcess(computer, process); + if(status < 0) + MessageBox.Show(this,"The process could not be stopped. Status: " + status ,"Process failed to stop",MessageBoxButtons.OK); + else + MessageBox.Show(this,"The process was sucessfully stopped!","Process stopped",MessageBoxButtons.OK); + } + + private int stopProcess(string computer, string process) + { + Computer c=computerMgmt.getComputer(computer); + int status = c.stopProcess(c.getProcessByName(process)); + return status; + } + + private void restartProcess(object sender, System.EventArgs e) + { + if(listView.SelectedItems.Count==0) + return; + string computer = listView.SelectedItems[0].SubItems[0].Text.ToString(); + string process = listView.SelectedItems[0].SubItems[2].Text.ToString(); + if(stopProcess(computer, process)<0) + { + MessageBox.Show("Restart process failed!!!", "Restart process"); + return; + } + if(startProcess(computer, process)<0) + { + MessageBox.Show("Restart process failed!!!", "Restart process"); + return; + } + MessageBox.Show("Succesfully restarted the process!","Restart process"); + } + + private void menuRefresh_Click(object sender, System.EventArgs e) + { + //string computer = tvComputerCluster.SelectedNode.Text; + + this.listProcesses(); + } + + private void importHostFile(object sender, System.EventArgs e) + { + openHostFileDialog.ShowDialog(); + } + + private void exportHostFile(object sender, System.EventArgs e) + { + saveHostFileDialog.ShowDialog(); + } + + private void listProcesses() + { + /* add process in computer list*/ + ArrayList computers = computerMgmt.getComputerCollection(); + foreach(Computer c in computers) + { + c.listProcesses(); + ArrayList processes = c.getProcesses(); + if(processes!=null) + { + foreach(Process p in processes) + { + Database db = computerMgmt.getDatabase(p.getDatabase()); + if(db!=null) + { + p.setDefined(true); + db.addProcessCheck(p); + } + } + } + } + updateListViews("Computer"); + updateListViews("Database"); + } + + private void openHostFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) + { + computerMgmt.importHostFile(openHostFileDialog.FileName); + this.updateTreeViews(); + openHostFileDialog.Dispose(); + listProcesses(); + } + + private void saveHostFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) + { + computerMgmt.exportHostFile(saveHostFileDialog.FileName); + saveHostFileDialog.Dispose(); + } + + private void mgmConsole_Enter(object sender, System.EventArgs e) + {/* + //telnetclient.telnetClient tc= new telnetclient.telnetClient("10.0.13.1",10000,mgmConsole); + socketcomm.SocketComm sc = new socketcomm.SocketComm("10.0.13.1",10000); + sc.doConnect(); + while(!sc.isConnected()) + { + Thread.Sleep(100); + } + sc.writeMessage("get status\r"); + string line = sc.readLine(); + while(!line.Equals("")) + { + MessageBox.Show(line); + line=sc.readLine(); + } +*/ + } + + private void mgmConsole_TextChanged(object sender, System.EventArgs e) + { + + } + + + + + + + + + + } + +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs new file mode 100644 index 00000000000..5ee35e5e90e --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs @@ -0,0 +1,271 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.IO; +using NDB_CPC.socketcomm; +using NDB_CPC.simpleparser; + + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for Computer. + /// </summary> + public class Computer + { + public enum Status {Disconnected=1,Connected=2, Unknown=3} + private string m_ip; + private int m_cpcdPort; + private string m_name; + private Status m_status; + private ArrayList m_processes; + private SocketComm m_socket; + public Computer(string name, int port) + { + m_name = name; + m_status = Status.Disconnected; + m_processes = new ArrayList(); + m_cpcdPort=port; + m_socket = new SocketComm(m_name,m_cpcdPort); + } + + public Computer(string name, string ip) + { + m_ip = ip; + m_name = name; + m_status = Status.Disconnected; + m_processes = new ArrayList(); + m_cpcdPort=1234; //default port + m_socket = new SocketComm(m_ip,m_cpcdPort); + } + + public void connectToCpcd() + { + m_socket.doConnect(); + } + + private bool sendMessage(string str) + { + return m_socket.writeMessage(str); + + } + + public string getName() {return m_name;} + public string getIp() {return m_ip;} + public ArrayList getProcesses() + { + if(m_processes.Count>0) + return m_processes; + else + return null; + } + public string getStatusString() + { + try + { + if(m_socket.isConnected()) + return "Connected"; + else + return "Disconnected"; + } + catch(Exception e) + { + return "Unknown"; + } + } + + + public bool isConnected() + { + if(m_socket.isConnected()) + return true; + return false; + } + + public Status getStatus() + { + try + { + if(m_socket.isConnected()) + return Status.Connected; + else + return Status.Disconnected; + } + catch(Exception e) + { + return Status.Unknown; + } + } + + public void setStatus(Status status) + { + m_status=status; + } + + public void addProcess(Process process) + { + m_processes.Add(process); + } + + public Process getProcessByName(string name) + { + foreach(Process process in m_processes) + { + if(process.getName().Equals(name)) + return process; + } + return null; + } + + + public bool removeProcess(string name, string database) + { + foreach(Process p in m_processes) + { + if(p.getName().Equals(name) && p.getDatabase().Equals(database)) + { + m_processes.Remove(p); + return true; + } + } + return false; + } + + public void disconnect() + { + m_socket.disconnect(); + } + public Process getProcess(string id) + { + foreach(Process process in m_processes) + { + if(process.getId().Equals(id)) + return process; + } + return null; + } + + public int listProcesses() + { + string list = "list processes\n\n"; + + if(!sendMessage(list)) + return -2; + + SimpleCPCParser.parse(m_processes, this, m_socket); + return 1; + } + + public int defineProcess(Process p) + { + string define = "define process \n"; + define = define + "name:" + p.getName() + "\n"; + define = define + "group:" + p.getDatabase() + "\n"; + define = define + "env:" + "NDB_CONNECTSTRING="+p.getConnectString() ; + if(p.getEnv().Equals("")) + define = define + "\n"; + else + define = define + " " + p.getEnv() + "\n"; + + //if(p.getPath().EndsWith("\\")) + // define = define + "path:" + p.getPath()+ "ndb" + "\n"; + //else + define = define + "path:" + p.getPath() + "\n"; + define = define + "args:" + p.getArgs() + "\n"; + define = define + "type:" + "permanent" + "\n"; + define = define + "cwd:" + p.getCwd() + "\n"; + define = define + "owner:" + "ejohson" + "\n\n"; + + if(!sendMessage(define)) + return -2; + + SimpleCPCParser.parse(p, m_socket); + if(p.isDefined()) + return 1; + else + return -1; + + } + + public int startProcess(Process p) + { + if(!p.isDefined()) + { + this.defineProcess(p); + if(!p.isDefined()) + return -4; //process misconfigured + + } + string start= "start process \n"; + start = start + "id:" + p.getId() + "\n\n"; + if(!sendMessage(start)) + return -2; + SimpleCPCParser.parse(p, m_socket); + if(p.getStatus().Equals(Process.Status.Running)) + return 1; + else + return -1; + } + + public int stopProcess(Process p) + { + if(!p.isDefined()) + { + return -4; //process not defined + } + string stop= "stop process \n"; + stop = stop + "id:" + p.getId() + "\n\n"; + if(!sendMessage(stop)) + return -2; + SimpleCPCParser.parse(p, m_socket); + + if(p.getStatus().Equals(Process.Status.Stopped)) + return 1; + else + return -1; + } + + public int undefineProcess(Process p) + { + if(!p.isDefined()) + { + return -4; //process not defined + } + string undefine= "undefine process \n"; + undefine = undefine + "id:" + p.getId() + "\n\n"; + if(!sendMessage(undefine)) + return -2; + SimpleCPCParser.parse(p, m_socket); + if(!p.isDefined()) + { + return 1; + + } + return -1; + } + + public int getCpcdPort() + { + return this.m_cpcdPort; + } + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs new file mode 100644 index 00000000000..506cb6777f0 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs @@ -0,0 +1,257 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for ComputerAddDialog. + /// </summary> + public class ComputerAddDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textboxComputerName; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Label label2; + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.Container components = null; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.CheckBox checkBoxDefault; + private System.Windows.Forms.TextBox textBoxPort; + + private ComputerMgmt mgmt; + public ComputerAddDialog(ComputerMgmt mgmt) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + this.mgmt=mgmt; + } + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.textboxComputerName = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.textBoxPort = new System.Windows.Forms.TextBox(); + this.checkBoxDefault = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // textboxComputerName + // + this.textboxComputerName.Location = new System.Drawing.Point(128, 16); + this.textboxComputerName.Name = "textboxComputerName"; + this.textboxComputerName.Size = new System.Drawing.Size(136, 20); + this.textboxComputerName.TabIndex = 0; + this.textboxComputerName.Text = ""; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(40, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(88, 23); + this.label1.TabIndex = 1; + this.label1.Text = "Computer name:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(112, 128); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(80, 24); + this.btnAdd.TabIndex = 4; + this.btnAdd.Text = "Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(200, 128); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(80, 24); + this.btnCancel.TabIndex = 5; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // label2 + // + this.label2.Location = new System.Drawing.Point(128, 40); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(136, 16); + this.label2.TabIndex = 4; + this.label2.Text = "(e.g. Ndb01 or 10.0.1.1)"; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(48, 64); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(80, 24); + this.label6.TabIndex = 9; + this.label6.Text = "CPCd port:"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // textBoxPort + // + this.textBoxPort.Enabled = false; + this.textBoxPort.Location = new System.Drawing.Point(128, 64); + this.textBoxPort.Name = "textBoxPort"; + this.textBoxPort.Size = new System.Drawing.Size(136, 20); + this.textBoxPort.TabIndex = 2; + this.textBoxPort.TabStop = false; + this.textBoxPort.Text = ""; + // + // checkBoxDefault + // + this.checkBoxDefault.Checked = true; + this.checkBoxDefault.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxDefault.Location = new System.Drawing.Point(96, 96); + this.checkBoxDefault.Name = "checkBoxDefault"; + this.checkBoxDefault.Size = new System.Drawing.Size(168, 16); + this.checkBoxDefault.TabIndex = 3; + this.checkBoxDefault.Text = "Use default port (1234)?"; + this.checkBoxDefault.CheckedChanged += new System.EventHandler(this.checkBoxDefault_CheckedChanged); + // + // ComputerAddDialog + // + this.AcceptButton = this.btnAdd; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(298, 159); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.checkBoxDefault, + this.label6, + this.textBoxPort, + this.label2, + this.btnCancel, + this.btnAdd, + this.label1, + this.textboxComputerName}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ComputerAddDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Add a computer"; + this.Load += new System.EventHandler(this.ComputerAddDialog_Load); + this.ResumeLayout(false); + + } + #endregion + + private void btnCancel_Click(object sender, System.EventArgs e) + { + this.Close(); + this.Dispose(); + } + + private void btnAdd_Click(object sender, System.EventArgs e) + { + int port; + if(this.textboxComputerName.Text.Equals("")) + { + MessageBox.Show(this,"A computer must have an IP address or a host name","Warning!",MessageBoxButtons.OK); + return; + } + if(this.checkBoxDefault.Checked) + { + port=1234; + } + else + { + if(this.textBoxPort.Text.Equals("")) + { + MessageBox.Show(this,"You must specify a port number!!!","Warning!",MessageBoxButtons.OK); + return; + } + else + { + try + { + port=Convert.ToInt32(this.textBoxPort.Text.ToString()); + + } + catch (Exception exception) + { + MessageBox.Show(this,"Port number must be numeric!!!","Warning!",MessageBoxButtons.OK); + return; + } + } + } + + if(mgmt.getComputer(this.textboxComputerName.Text)==null) + { + mgmt.AddComputer(this.textboxComputerName.Text.ToString(),port);} + else + { + MessageBox.Show("This computer does already exist!", "Add computer"); + return; + } + + this.Dispose(); + } + + private void ComputerAddDialog_Load(object sender, System.EventArgs e) + { + + } + + private void checkBoxDefault_CheckedChanged(object sender, System.EventArgs e) + { + if(checkBoxDefault.Checked) + textBoxPort.Enabled=false; + else + textBoxPort.Enabled=true; + } + + + + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs new file mode 100644 index 00000000000..a126c632ffd --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs @@ -0,0 +1,243 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for ComputerRemoveDialog. + /// </summary> + public class ComputerRemoveDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboComputer; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnRemove; + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.Container components = null; + private ComputerMgmt mgmt; + + public ComputerRemoveDialog(ComputerMgmt mgmt) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + this.mgmt=mgmt; + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ComputerRemoveDialog)); + this.label1 = new System.Windows.Forms.Label(); + this.comboComputer = new System.Windows.Forms.ComboBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnRemove = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AccessibleDescription = ((string)(resources.GetObject("label1.AccessibleDescription"))); + this.label1.AccessibleName = ((string)(resources.GetObject("label1.AccessibleName"))); + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor"))); + this.label1.AutoSize = ((bool)(resources.GetObject("label1.AutoSize"))); + this.label1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label1.Dock"))); + this.label1.Enabled = ((bool)(resources.GetObject("label1.Enabled"))); + this.label1.Font = ((System.Drawing.Font)(resources.GetObject("label1.Font"))); + this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image"))); + this.label1.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.ImageAlign"))); + this.label1.ImageIndex = ((int)(resources.GetObject("label1.ImageIndex"))); + this.label1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label1.ImeMode"))); + this.label1.Location = ((System.Drawing.Point)(resources.GetObject("label1.Location"))); + this.label1.Name = "label1"; + this.label1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label1.RightToLeft"))); + this.label1.Size = ((System.Drawing.Size)(resources.GetObject("label1.Size"))); + this.label1.TabIndex = ((int)(resources.GetObject("label1.TabIndex"))); + this.label1.Text = resources.GetString("label1.Text"); + this.label1.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.TextAlign"))); + this.label1.Visible = ((bool)(resources.GetObject("label1.Visible"))); + // + // comboComputer + // + this.comboComputer.AccessibleDescription = ((string)(resources.GetObject("comboComputer.AccessibleDescription"))); + this.comboComputer.AccessibleName = ((string)(resources.GetObject("comboComputer.AccessibleName"))); + this.comboComputer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("comboComputer.Anchor"))); + this.comboComputer.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("comboComputer.BackgroundImage"))); + this.comboComputer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("comboComputer.Dock"))); + this.comboComputer.Enabled = ((bool)(resources.GetObject("comboComputer.Enabled"))); + this.comboComputer.Font = ((System.Drawing.Font)(resources.GetObject("comboComputer.Font"))); + this.comboComputer.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("comboComputer.ImeMode"))); + this.comboComputer.IntegralHeight = ((bool)(resources.GetObject("comboComputer.IntegralHeight"))); + this.comboComputer.ItemHeight = ((int)(resources.GetObject("comboComputer.ItemHeight"))); + this.comboComputer.Location = ((System.Drawing.Point)(resources.GetObject("comboComputer.Location"))); + this.comboComputer.MaxDropDownItems = ((int)(resources.GetObject("comboComputer.MaxDropDownItems"))); + this.comboComputer.MaxLength = ((int)(resources.GetObject("comboComputer.MaxLength"))); + this.comboComputer.Name = "comboComputer"; + this.comboComputer.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("comboComputer.RightToLeft"))); + this.comboComputer.Size = ((System.Drawing.Size)(resources.GetObject("comboComputer.Size"))); + this.comboComputer.Sorted = true; + this.comboComputer.TabIndex = ((int)(resources.GetObject("comboComputer.TabIndex"))); + this.comboComputer.Text = resources.GetString("comboComputer.Text"); + this.comboComputer.Visible = ((bool)(resources.GetObject("comboComputer.Visible"))); + this.comboComputer.SelectedIndexChanged += new System.EventHandler(this.comboComputer_SelectedIndexChanged); + // + // btnCancel + // + this.btnCancel.AccessibleDescription = ((string)(resources.GetObject("btnCancel.AccessibleDescription"))); + this.btnCancel.AccessibleName = ((string)(resources.GetObject("btnCancel.AccessibleName"))); + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCancel.Anchor"))); + this.btnCancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCancel.BackgroundImage"))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCancel.Dock"))); + this.btnCancel.Enabled = ((bool)(resources.GetObject("btnCancel.Enabled"))); + this.btnCancel.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCancel.FlatStyle"))); + this.btnCancel.Font = ((System.Drawing.Font)(resources.GetObject("btnCancel.Font"))); + this.btnCancel.Image = ((System.Drawing.Image)(resources.GetObject("btnCancel.Image"))); + this.btnCancel.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCancel.ImageAlign"))); + this.btnCancel.ImageIndex = ((int)(resources.GetObject("btnCancel.ImageIndex"))); + this.btnCancel.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCancel.ImeMode"))); + this.btnCancel.Location = ((System.Drawing.Point)(resources.GetObject("btnCancel.Location"))); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCancel.RightToLeft"))); + this.btnCancel.Size = ((System.Drawing.Size)(resources.GetObject("btnCancel.Size"))); + this.btnCancel.TabIndex = ((int)(resources.GetObject("btnCancel.TabIndex"))); + this.btnCancel.Text = resources.GetString("btnCancel.Text"); + this.btnCancel.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCancel.TextAlign"))); + this.btnCancel.Visible = ((bool)(resources.GetObject("btnCancel.Visible"))); + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnRemove + // + this.btnRemove.AccessibleDescription = ((string)(resources.GetObject("btnRemove.AccessibleDescription"))); + this.btnRemove.AccessibleName = ((string)(resources.GetObject("btnRemove.AccessibleName"))); + this.btnRemove.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnRemove.Anchor"))); + this.btnRemove.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnRemove.BackgroundImage"))); + this.btnRemove.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnRemove.Dock"))); + this.btnRemove.Enabled = ((bool)(resources.GetObject("btnRemove.Enabled"))); + this.btnRemove.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnRemove.FlatStyle"))); + this.btnRemove.Font = ((System.Drawing.Font)(resources.GetObject("btnRemove.Font"))); + this.btnRemove.Image = ((System.Drawing.Image)(resources.GetObject("btnRemove.Image"))); + this.btnRemove.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnRemove.ImageAlign"))); + this.btnRemove.ImageIndex = ((int)(resources.GetObject("btnRemove.ImageIndex"))); + this.btnRemove.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnRemove.ImeMode"))); + this.btnRemove.Location = ((System.Drawing.Point)(resources.GetObject("btnRemove.Location"))); + this.btnRemove.Name = "btnRemove"; + this.btnRemove.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnRemove.RightToLeft"))); + this.btnRemove.Size = ((System.Drawing.Size)(resources.GetObject("btnRemove.Size"))); + this.btnRemove.TabIndex = ((int)(resources.GetObject("btnRemove.TabIndex"))); + this.btnRemove.Text = resources.GetString("btnRemove.Text"); + this.btnRemove.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnRemove.TextAlign"))); + this.btnRemove.Visible = ((bool)(resources.GetObject("btnRemove.Visible"))); + this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click); + // + // ComputerRemoveDialog + // + this.AcceptButton = this.btnRemove; + this.AccessibleDescription = ((string)(resources.GetObject("$this.AccessibleDescription"))); + this.AccessibleName = ((string)(resources.GetObject("$this.AccessibleName"))); + this.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("$this.Anchor"))); + this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize"))); + this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll"))); + this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin"))); + this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize"))); + this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); + this.CancelButton = this.btnCancel; + this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize"))); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.btnRemove, + this.btnCancel, + this.comboComputer, + this.label1}); + this.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("$this.Dock"))); + this.Enabled = ((bool)(resources.GetObject("$this.Enabled"))); + this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font"))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode"))); + this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location"))); + this.MaximizeBox = false; + this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize"))); + this.MinimizeBox = false; + this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize"))); + this.Name = "ComputerRemoveDialog"; + this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft"))); + this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition"))); + this.Text = resources.GetString("$this.Text"); + this.Visible = ((bool)(resources.GetObject("$this.Visible"))); + this.Load += new System.EventHandler(this.ComputerRemoveDialog_Load); + this.ResumeLayout(false); + + } + #endregion + + private void btnRemove_Click(object sender, System.EventArgs e) + { + mgmt.RemoveComputer(comboComputer.SelectedItem.ToString()); + this.Dispose(); + } + + private void ComputerRemoveDialog_Load(object sender, System.EventArgs e) + { + ArrayList list = mgmt.getComputerCollection(); + foreach (Computer computer in list) + { + comboComputer.Items.Add(computer.getName()); + } + } + + private void btnCancel_Click(object sender, System.EventArgs e) + { + this.Close(); + this.Dispose(); + } + + private void comboComputer_SelectedIndexChanged(object sender, System.EventArgs e) + { + } + + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO b/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO Binary files differnew file mode 100644 index 00000000000..9689aa88361 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs new file mode 100644 index 00000000000..80a8daee2d0 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs @@ -0,0 +1,177 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for Database. + /// </summary> + public class Database + { + public enum Status {Disconnected=1,Connected=2, Unknown=3} + private string m_name; + private string m_owner; + private int m_mgmtPort; + private Status m_status; + private ArrayList m_processes; + public Database(string name) + { + m_name=name; + m_processes = new ArrayList(); + } + public Database(string name, string owner) + { + m_name=name; + m_owner=owner; + m_processes = new ArrayList(); + } + public Database() + { + m_processes = new ArrayList(); + } + + public string getName() + { + return m_name; + } + + public void setName(string name) + { + m_name=name; + } + + public void setMgmtPort(int port) + { + m_mgmtPort=port; + } + + public string getOwner() + { + return m_owner; + } + + public void setOwner(string name) + { + m_owner=name; + } + + + public Status getStatus() + { + return m_status; + } + + public string getStatusString() + { + if(m_status.Equals(Status.Connected)) + return "Connected"; + if(m_status.Equals(Status.Disconnected)) + return "Disconnected"; + if(m_status.Equals(Status.Unknown)) + return "Unknown"; + return "Unknown"; + } + public void setStatus(Status status) + { + m_status=status; + } + + public void addProcess(Process process) + { + /*if(check) + { + if(m_processes==null) + return; + if(m_processes.Count>0) + { + foreach (Process p in m_processes) + { + if(process.getId().Equals(p.getId())) + return; + } + } + } + */ + m_processes.Add(process); + } + public void addProcessCheck(Process process) + { + + if(m_processes==null) + return; + if(m_processes.Count>0) + { + foreach (Process p in m_processes) + { + if(process.getId().Equals(p.getId())) + return; + } + } + m_processes.Add(process); + } + + public Process getProcess(string id) + { + foreach(Process process in m_processes) + { + if(process.getId().Equals(id)) + return process; + } + return null; + } + + public Process getProcessByName(string name) + { + foreach(Process process in m_processes) + { + if(process.getName().Equals(name)) + return process; + } + return null; + } + + public void removeProcess( string processName) + { + Process p = this.getProcessByName(processName); + m_processes.Remove(p); + } + + public void removeAllProcesses() + { + Computer c; + foreach(Process p in m_processes) + { + c=p.getComputer(); + if(c.removeProcess(p.getName(),m_name).Equals(false)) + { + + } + } + m_processes.Clear(); + } + + public ArrayList getProcesses() + { + return m_processes; + } + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj new file mode 100644 index 00000000000..6384eff8329 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj @@ -0,0 +1,240 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.0.9466" + SchemaVersion = "1.0" + ProjectGuid = "{B78F6720-D36C-43DD-B442-F583718D0286}" + > + <Build> + <Settings + ApplicationIcon = "App.ico" + AssemblyKeyContainerName = "" + AssemblyName = "NDB_CPC" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "WinExe" + RootNamespace = "NDB_CPC" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "true" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System.Data" + AssemblyName = "System.Data" + HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll" + /> + <Reference + Name = "System.Drawing" + AssemblyName = "System.Drawing" + HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Drawing.dll" + /> + <Reference + Name = "System.Windows.Forms" + AssemblyName = "System.Windows.Forms" + HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Windows.Forms.dll" + /> + <Reference + Name = "System.XML" + AssemblyName = "System.Xml" + HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" + /> + <Reference + Name = "System" + AssemblyName = "System" + HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll" + /> + <Reference + Name = "VBIDE" + Guid = "{0002E157-0000-0000-C000-000000000046}" + VersionMajor = "5" + VersionMinor = "3" + Lcid = "0" + WrapperTool = "tlbimp" + /> + <Reference + Name = "stdole" + Guid = "{00020430-0000-0000-C000-000000000046}" + VersionMajor = "2" + VersionMinor = "0" + Lcid = "0" + WrapperTool = "primary" + /> + <Reference + Name = "Microsoft.Office.Core" + Guid = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}" + VersionMajor = "2" + VersionMinor = "2" + Lcid = "0" + WrapperTool = "tlbimp" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "app.config" + BuildAction = "None" + /> + <File + RelPath = "App.ico" + BuildAction = "Content" + /> + <File + RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Computer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ComputerAddDialog.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "ComputerAddDialog.resx" + DependentUpon = "ComputerAddDialog.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "ComputerMgmt.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ComputerRemoveDialog.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "ComputerRemoveDialog.af.resx" + DependentUpon = "ComputerRemoveDialog.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "ComputerRemoveDialog.resx" + DependentUpon = "ComputerRemoveDialog.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "CPC_Form.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "CPC_Form.resx" + DependentUpon = "CPC_Form.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Database.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "PanelWizard.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "PanelWizard.resx" + DependentUpon = "PanelWizard.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Process.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ProcessDefineDialog.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "ProcessDefineDialog.resx" + DependentUpon = "ProcessDefineDialog.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "startDatabaseDlg.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "startDatabaseDlg.resx" + DependentUpon = "startDatabaseDlg.cs" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "fileaccess\FileMgmt.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "simpleparser\SimpleCPCParser.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "socketcomm\myTcpClient.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "socketcomm\SocketComm.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "telnetclient\telnetClient.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user new file mode 100644 index 00000000000..68937906d93 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user @@ -0,0 +1,48 @@ +<VisualStudioProject> + <CSHARP> + <Build> + <Settings ReferencePath = "" > + <Config + Name = "Debug" + EnableASPDebugging = "false" + EnableASPXDebugging = "false" + EnableUnmanagedDebugging = "false" + EnableSQLServerDebugging = "false" + RemoteDebugEnabled = "false" + RemoteDebugMachine = "" + StartAction = "Project" + StartArguments = "" + StartPage = "" + StartProgram = "" + StartURL = "" + StartWorkingDirectory = "" + StartWithIE = "false" + /> + <Config + Name = "Release" + EnableASPDebugging = "false" + EnableASPXDebugging = "false" + EnableUnmanagedDebugging = "false" + EnableSQLServerDebugging = "false" + RemoteDebugEnabled = "false" + RemoteDebugMachine = "" + StartAction = "Project" + StartArguments = "" + StartPage = "" + StartProgram = "" + StartURL = "" + StartWorkingDirectory = "" + StartWithIE = "true" + /> + </Settings> + </Build> + <OtherProjectSettings + CopyProjectDestinationFolder = "" + CopyProjectUncPath = "" + CopyProjectOption = "0" + ProjectView = "ProjectFiles" + ProjectTrust = "0" + /> + </CSHARP> +</VisualStudioProject> + diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb Binary files differnew file mode 100644 index 00000000000..ed3460476b0 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln new file mode 100644 index 00000000000..ef18b5e94ce --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB_CPC", "NDB_CPC.csproj", "{B78F6720-D36C-43DD-B442-F583718D0286}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B78F6720-D36C-43DD-B442-F583718D0286}.Debug.ActiveCfg = Debug|.NET + {B78F6720-D36C-43DD-B442-F583718D0286}.Debug.Build.0 = Debug|.NET + {B78F6720-D36C-43DD-B442-F583718D0286}.Release.ActiveCfg = Release|.NET + {B78F6720-D36C-43DD-B442-F583718D0286}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs new file mode 100644 index 00000000000..a780190f86c --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs @@ -0,0 +1,1898 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +//author:Arun +//date:Nov 13,2002 +//Wizard using panel +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for MDXQueryBuilderWizard. + /// </summary> + public class PanelWizard : System.Windows.Forms.Form + { + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnback; + private System.Windows.Forms.Button btnNext; + private System.Windows.Forms.Button btnFinish; + + //---enabling and disabling the buttons + private bool cancelEnabled; + private bool backEnabled; + private bool nextEnabled; + private bool finishEnabled; + //-------- + //--set the next and back panel + private Panel nextPanel; + private Panel backPanel; + private Panel presentPanel; + // + private Panel[] arrayPanel; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.RadioButton radioBtnYes; + private System.Windows.Forms.RadioButton radioBtnNo; + private System.Windows.Forms.ListBox listBoxComputers; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label1; + private System.ComponentModel.IContainer components; + private System.Windows.Forms.Button buttonComputerAdd; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.ComboBox comboNDB; + private System.Windows.Forms.ComboBox comboAPI; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.ComboBox comboMGM; + private System.Windows.Forms.Button btnTransferNodeToComp; + private System.Windows.Forms.TreeView tvComputer; + private System.Windows.Forms.ListView lvNode; + private System.Windows.Forms.Button btnTransferCompToNode; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private int m_nMGM; + private ComputerMgmt mgmt; + private int m_nNDB; + private int m_nAPI; + private Database m_db; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.TextBox textDbName; + private System.Windows.Forms.Label label31; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.Label labelTitle; + private System.Windows.Forms.Label labelCwd; + private System.Windows.Forms.Label labelArgs; + private System.Windows.Forms.Label labelOther; + private System.Windows.Forms.Label labelPath; + private int m_noOfConfiguredNodes; + private int m_noOfConfiguredMgmt; + private int m_noOfConfiguredNdb; + private string m_mgmHost; + private string m_mgmPort; + private System.Windows.Forms.TextBox textCwd; + private System.Windows.Forms.TextBox textArgs; + private System.Windows.Forms.TextBox textOther; + private System.Windows.Forms.TextBox textPath; + private System.Windows.Forms.TextBox textComputer; + private System.Windows.Forms.TextBox textDatabase; + private System.Windows.Forms.TextBox textName; + private int m_noOfConfiguredApi; + private bool m_bMgmt; + private System.Windows.Forms.Button buttonSave; + private System.Windows.Forms.CheckBox checkBoxReuse; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.CheckBox checkBoxLater; + private System.Windows.Forms.RadioButton radioYes; + private System.Windows.Forms.RadioButton radioNo; + private System.Windows.Forms.Panel panel6; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.RadioButton radioStartNo; + private System.Windows.Forms.RadioButton radioStartYes; + private System.Windows.Forms.ImageList imageListComp; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox textOwner; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.TextBox textEnv; + private bool m_bNdb; + public PanelWizard(ComputerMgmt comp) + { + mgmt=comp; + m_noOfConfiguredNodes=0; + m_noOfConfiguredMgmt=0; + m_noOfConfiguredNdb=0; + m_noOfConfiguredApi=0; + Size panelSize= new Size(350,300); + Size s= new Size(355,360); + Point cancel= new Point(8,310); + Point back= new Point(96,310); + Point next = new Point(184,310); + Point finish= new Point(272,310); + InitializeComponent(); + this.Size=s; + this.btnCancel.Location=cancel; + + this.btnback.Location=back; + this.btnNext.Location=next; + this.btnFinish.Location=finish; + + arrayPanel=new Panel[]{panel1,panel2,panel3,panel4,panel5,panel6};//,panel5, panel6}; + panel1.Size=panelSize; + + comboNDB.SelectedIndex=0; + comboAPI.SelectedIndex=0; + comboMGM.SelectedIndex=0; + m_bMgmt=false; + m_bNdb=false; + + m_db = new Database(); + if(listBoxComputers.Items.Count.Equals(0)) + btnNext.Enabled=false; + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PanelWizard)); + this.panel1 = new System.Windows.Forms.Panel(); + this.buttonComputerAdd = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.listBoxComputers = new System.Windows.Forms.ListBox(); + this.radioBtnNo = new System.Windows.Forms.RadioButton(); + this.radioBtnYes = new System.Windows.Forms.RadioButton(); + this.panel2 = new System.Windows.Forms.Panel(); + this.label12 = new System.Windows.Forms.Label(); + this.textOwner = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.textDbName = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.comboMGM = new System.Windows.Forms.ComboBox(); + this.comboAPI = new System.Windows.Forms.ComboBox(); + this.comboNDB = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.checkBoxLater = new System.Windows.Forms.CheckBox(); + this.label10 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.btnTransferCompToNode = new System.Windows.Forms.Button(); + this.btnTransferNodeToComp = new System.Windows.Forms.Button(); + this.lvNode = new System.Windows.Forms.ListView(); + this.tvComputer = new System.Windows.Forms.TreeView(); + this.imageListComp = new System.Windows.Forms.ImageList(this.components); + this.panel6 = new System.Windows.Forms.Panel(); + this.radioStartNo = new System.Windows.Forms.RadioButton(); + this.radioStartYes = new System.Windows.Forms.RadioButton(); + this.label18 = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnback = new System.Windows.Forms.Button(); + this.btnNext = new System.Windows.Forms.Button(); + this.btnFinish = new System.Windows.Forms.Button(); + this.panel4 = new System.Windows.Forms.Panel(); + this.textEnv = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.checkBoxReuse = new System.Windows.Forms.CheckBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.labelTitle = new System.Windows.Forms.Label(); + this.textComputer = new System.Windows.Forms.TextBox(); + this.textCwd = new System.Windows.Forms.TextBox(); + this.textArgs = new System.Windows.Forms.TextBox(); + this.textOther = new System.Windows.Forms.TextBox(); + this.textPath = new System.Windows.Forms.TextBox(); + this.textDatabase = new System.Windows.Forms.TextBox(); + this.textName = new System.Windows.Forms.TextBox(); + this.labelCwd = new System.Windows.Forms.Label(); + this.labelArgs = new System.Windows.Forms.Label(); + this.labelOther = new System.Windows.Forms.Label(); + this.labelPath = new System.Windows.Forms.Label(); + this.label31 = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); + this.label33 = new System.Windows.Forms.Label(); + this.panel5 = new System.Windows.Forms.Panel(); + this.radioNo = new System.Windows.Forms.RadioButton(); + this.radioYes = new System.Windows.Forms.RadioButton(); + this.label4 = new System.Windows.Forms.Label(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel6.SuspendLayout(); + this.panel4.SuspendLayout(); + this.panel5.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] { + this.buttonComputerAdd, + this.label1, + this.label5, + this.listBoxComputers, + this.radioBtnNo, + this.radioBtnYes}); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(344, 312); + this.panel1.TabIndex = 0; + this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); + // + // buttonComputerAdd + // + this.buttonComputerAdd.Enabled = false; + this.buttonComputerAdd.Location = new System.Drawing.Point(192, 232); + this.buttonComputerAdd.Name = "buttonComputerAdd"; + this.buttonComputerAdd.Size = new System.Drawing.Size(96, 24); + this.buttonComputerAdd.TabIndex = 3; + this.buttonComputerAdd.Text = "Add computer..."; + this.buttonComputerAdd.Click += new System.EventHandler(this.buttonComputerAdd_Click); + // + // label1 + // + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label1.Location = new System.Drawing.Point(80, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(200, 23); + this.label1.TabIndex = 5; + this.label1.Text = "Configure computers"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label5 + // + this.label5.Location = new System.Drawing.Point(24, 40); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(128, 23); + this.label5.TabIndex = 4; + this.label5.Text = "Available computers:"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // listBoxComputers + // + this.listBoxComputers.Location = new System.Drawing.Point(24, 64); + this.listBoxComputers.Name = "listBoxComputers"; + this.listBoxComputers.Size = new System.Drawing.Size(128, 212); + this.listBoxComputers.TabIndex = 3; + this.listBoxComputers.SelectedIndexChanged += new System.EventHandler(this.listBoxComputers_SelectedIndexChanged); + // + // radioBtnNo + // + this.radioBtnNo.AutoCheck = false; + this.radioBtnNo.Location = new System.Drawing.Point(168, 168); + this.radioBtnNo.Name = "radioBtnNo"; + this.radioBtnNo.Size = new System.Drawing.Size(152, 64); + this.radioBtnNo.TabIndex = 2; + this.radioBtnNo.Text = "No, I have to add more computers in order to deploy NDB Cluster. "; + this.radioBtnNo.Click += new System.EventHandler(this.radioBtnNo_Click); + // + // radioBtnYes + // + this.radioBtnYes.AutoCheck = false; + this.radioBtnYes.Location = new System.Drawing.Point(168, 72); + this.radioBtnYes.Name = "radioBtnYes"; + this.radioBtnYes.Size = new System.Drawing.Size(152, 80); + this.radioBtnYes.TabIndex = 1; + this.radioBtnYes.Text = "Yes, all the computers that I need to deploy NDB Cluster exists in the list \"Avai" + + "lable computers\""; + this.radioBtnYes.Click += new System.EventHandler(this.radioBtnYes_Click); + // + // panel2 + // + this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] { + this.label12, + this.textOwner, + this.label11, + this.textDbName, + this.label8, + this.label7, + this.label6, + this.comboMGM, + this.comboAPI, + this.comboNDB, + this.label2}); + this.panel2.Location = new System.Drawing.Point(0, 320); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(344, 312); + this.panel2.TabIndex = 1; + this.panel2.Validating += new System.ComponentModel.CancelEventHandler(this.panel2_Validating); + this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint); + // + // label12 + // + this.label12.Location = new System.Drawing.Point(72, 216); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(112, 24); + this.label12.TabIndex = 16; + this.label12.Text = "Database owner:"; + this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // textOwner + // + this.textOwner.Location = new System.Drawing.Point(192, 216); + this.textOwner.Name = "textOwner"; + this.textOwner.TabIndex = 5; + this.textOwner.Text = ""; + this.textOwner.TextChanged += new System.EventHandler(this.textOwner_TextChanged); + // + // label11 + // + this.label11.Location = new System.Drawing.Point(72, 184); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(112, 24); + this.label11.TabIndex = 14; + this.label11.Text = "Database name:"; + this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label11.Click += new System.EventHandler(this.label11_Click); + // + // textDbName + // + this.textDbName.Location = new System.Drawing.Point(192, 184); + this.textDbName.Name = "textDbName"; + this.textDbName.TabIndex = 4; + this.textDbName.Text = ""; + + this.textDbName.TextChanged += new System.EventHandler(this.textDbName_TextChanged); + // + // label8 + // + this.label8.Location = new System.Drawing.Point(16, 120); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(176, 24); + this.label8.TabIndex = 12; + this.label8.Text = "Number of management servers:"; + this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label7 + // + this.label7.Location = new System.Drawing.Point(16, 88); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(120, 24); + this.label7.TabIndex = 11; + this.label7.Text = "Number of API nodes:"; + this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(16, 56); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(144, 24); + this.label6.TabIndex = 10; + this.label6.Text = "Number of database nodes:"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // comboMGM + // + this.comboMGM.DisplayMember = "0"; + this.comboMGM.Items.AddRange(new object[] { + "1"}); + this.comboMGM.Location = new System.Drawing.Point(192, 120); + this.comboMGM.Name = "comboMGM"; + this.comboMGM.Size = new System.Drawing.Size(104, 21); + this.comboMGM.TabIndex = 3; + this.comboMGM.Text = "comboBox3"; + // + // comboAPI + // + this.comboAPI.DisplayMember = "0"; + this.comboAPI.Items.AddRange(new object[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10"}); + this.comboAPI.Location = new System.Drawing.Point(192, 88); + this.comboAPI.Name = "comboAPI"; + this.comboAPI.Size = new System.Drawing.Size(104, 21); + this.comboAPI.TabIndex = 2; + this.comboAPI.Text = "comboBox2"; + // + // comboNDB + // + this.comboNDB.DisplayMember = "0"; + this.comboNDB.Items.AddRange(new object[] { + "1", + "2", + "4", + "8"}); + this.comboNDB.Location = new System.Drawing.Point(192, 56); + this.comboNDB.Name = "comboNDB"; + this.comboNDB.Size = new System.Drawing.Size(104, 21); + this.comboNDB.TabIndex = 1; + this.comboNDB.Text = "comboBox1"; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label2.Location = new System.Drawing.Point(80, 8); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(208, 23); + this.label2.TabIndex = 6; + this.label2.Text = "Setup NDB Cluster nodes"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel3 + // + this.panel3.Controls.AddRange(new System.Windows.Forms.Control[] { + this.checkBoxLater, + this.label10, + this.label9, + this.label3, + this.btnTransferCompToNode, + this.btnTransferNodeToComp, + this.lvNode, + this.tvComputer}); + this.panel3.Location = new System.Drawing.Point(360, 8); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(320, 312); + this.panel3.TabIndex = 2; + // + // checkBoxLater + // + this.checkBoxLater.Location = new System.Drawing.Point(40, 256); + this.checkBoxLater.Name = "checkBoxLater"; + this.checkBoxLater.Size = new System.Drawing.Size(240, 16); + this.checkBoxLater.TabIndex = 9; + this.checkBoxLater.Text = "I will configure these nodes manually, later."; + // + // label10 + // + this.label10.Location = new System.Drawing.Point(16, 40); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(104, 16); + this.label10.TabIndex = 8; + this.label10.Text = "NDB Cluster nodes:"; + this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label9 + // + this.label9.Location = new System.Drawing.Point(192, 40); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(100, 16); + this.label9.TabIndex = 7; + this.label9.Text = "Computers:"; + this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label3 + // + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label3.Location = new System.Drawing.Point(40, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(280, 23); + this.label3.TabIndex = 6; + this.label3.Text = "Assign NDB nodes to computers"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // btnTransferCompToNode + // + this.btnTransferCompToNode.Location = new System.Drawing.Point(144, 160); + this.btnTransferCompToNode.Name = "btnTransferCompToNode"; + this.btnTransferCompToNode.Size = new System.Drawing.Size(40, 24); + this.btnTransferCompToNode.TabIndex = 4; + this.btnTransferCompToNode.Text = "<---"; + // + // btnTransferNodeToComp + // + this.btnTransferNodeToComp.Location = new System.Drawing.Point(144, 128); + this.btnTransferNodeToComp.Name = "btnTransferNodeToComp"; + this.btnTransferNodeToComp.Size = new System.Drawing.Size(40, 24); + this.btnTransferNodeToComp.TabIndex = 3; + this.btnTransferNodeToComp.Text = "--->"; + this.btnTransferNodeToComp.Click += new System.EventHandler(this.btnTransferNodeToComp_Click); + // + // lvNode + // + this.lvNode.HideSelection = false; + this.lvNode.Location = new System.Drawing.Point(16, 56); + this.lvNode.Name = "lvNode"; + this.lvNode.Size = new System.Drawing.Size(112, 192); + this.lvNode.TabIndex = 2; + this.lvNode.View = System.Windows.Forms.View.List; + this.lvNode.SelectedIndexChanged += new System.EventHandler(this.lvNode_SelectedIndexChanged); + // + // tvComputer + // + this.tvComputer.HideSelection = false; + this.tvComputer.ImageList = this.imageListComp; + this.tvComputer.Location = new System.Drawing.Point(192, 56); + this.tvComputer.Name = "tvComputer"; + this.tvComputer.Size = new System.Drawing.Size(120, 192); + this.tvComputer.TabIndex = 1; + this.tvComputer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvComputer_MouseDown); + this.tvComputer.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvComputer_AfterSelect); + this.tvComputer.MouseLeave += new System.EventHandler(this.tvComputer_MouseLeave); + this.tvComputer.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvComputer_DragDrop); + // + // imageListComp + // + this.imageListComp.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; + this.imageListComp.ImageSize = new System.Drawing.Size(16, 16); + this.imageListComp.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListComp.ImageStream"))); + this.imageListComp.TransparentColor = System.Drawing.Color.Transparent; + // + // panel6 + // + this.panel6.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioStartNo, + this.radioStartYes, + this.label18}); + this.panel6.Location = new System.Drawing.Point(344, 336); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(344, 312); + this.panel6.TabIndex = 3; + this.panel6.Paint += new System.Windows.Forms.PaintEventHandler(this.panel4_Paint); + // + // radioStartNo + // + this.radioStartNo.Location = new System.Drawing.Point(40, 144); + this.radioStartNo.Name = "radioStartNo"; + this.radioStartNo.Size = new System.Drawing.Size(272, 48); + this.radioStartNo.TabIndex = 81; + this.radioStartNo.Text = "Manually start NDB Cluster. The Magician will exit and you must start NDB Cluster" + + " manually."; + this.radioStartNo.CheckedChanged += new System.EventHandler(this.radioStartNo_CheckedChanged); + // + // radioStartYes + // + this.radioStartYes.Location = new System.Drawing.Point(40, 40); + this.radioStartYes.Name = "radioStartYes"; + this.radioStartYes.Size = new System.Drawing.Size(272, 88); + this.radioStartYes.TabIndex = 80; + this.radioStartYes.Text = "Start NDB Cluster now. The Magician will start NDB Cluster and exit. MAKE SURE YO" + + "U HAVE STARTED THE MGMTSRVR WITH THE CORRECT CONFIGURATION FILE!!!"; + this.radioStartYes.CheckedChanged += new System.EventHandler(this.radioStartYes_CheckedChanged); + // + // label18 + // + this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label18.Location = new System.Drawing.Point(56, 8); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(224, 24); + this.label18.TabIndex = 79; + this.label18.Text = "Start NDB Cluster and finish"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(8, 656); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(70, 23); + this.btnCancel.TabIndex = 10; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnback + // + this.btnback.Location = new System.Drawing.Point(96, 656); + this.btnback.Name = "btnback"; + this.btnback.Size = new System.Drawing.Size(70, 23); + this.btnback.TabIndex = 11; + this.btnback.Text = "< Back"; + this.btnback.Click += new System.EventHandler(this.btnback_Click); + // + // btnNext + // + this.btnNext.Location = new System.Drawing.Point(184, 656); + this.btnNext.Name = "btnNext"; + this.btnNext.Size = new System.Drawing.Size(70, 23); + this.btnNext.TabIndex = 12; + this.btnNext.Text = "Next >"; + this.btnNext.Click += new System.EventHandler(this.btnNext_Click); + // + // btnFinish + // + this.btnFinish.Location = new System.Drawing.Point(272, 656); + this.btnFinish.Name = "btnFinish"; + this.btnFinish.Size = new System.Drawing.Size(70, 23); + this.btnFinish.TabIndex = 13; + this.btnFinish.Text = "Finish"; + this.btnFinish.Click += new System.EventHandler(this.btnFinish_Click); + // + // panel4 + // + this.panel4.Controls.AddRange(new System.Windows.Forms.Control[] { + this.textEnv, + this.label13, + this.checkBoxReuse, + this.buttonSave, + this.labelTitle, + this.textComputer, + this.textCwd, + this.textArgs, + this.textOther, + this.textPath, + this.textDatabase, + this.textName, + this.labelCwd, + this.labelArgs, + this.labelOther, + this.labelPath, + this.label31, + this.label32, + this.label33}); + this.panel4.Location = new System.Drawing.Point(672, 8); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(344, 312); + this.panel4.TabIndex = 62; + this.panel4.Paint += new System.Windows.Forms.PaintEventHandler(this.panel5_Paint); + // + // textEnv + // + this.textEnv.Location = new System.Drawing.Point(136, 136); + this.textEnv.Name = "textEnv"; + this.textEnv.Size = new System.Drawing.Size(184, 20); + this.textEnv.TabIndex = 2; + this.textEnv.TabStop = false; + this.textEnv.Text = ""; + // + // label13 + // + this.label13.Location = new System.Drawing.Point(8, 136); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(136, 24); + this.label13.TabIndex = 81; + this.label13.Text = "Environment variables:"; + // + // checkBoxReuse + // + this.checkBoxReuse.Location = new System.Drawing.Point(88, 232); + this.checkBoxReuse.Name = "checkBoxReuse"; + this.checkBoxReuse.Size = new System.Drawing.Size(240, 32); + this.checkBoxReuse.TabIndex = 5; + this.checkBoxReuse.TabStop = false; + this.checkBoxReuse.Text = "Use the same configuration for ALL NDB nodes?"; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(184, 264); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(88, 24); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Save"; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // labelTitle + // + this.labelTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.labelTitle.Location = new System.Drawing.Point(80, 16); + this.labelTitle.Name = "labelTitle"; + this.labelTitle.Size = new System.Drawing.Size(192, 23); + this.labelTitle.TabIndex = 79; + this.labelTitle.Text = "Mgmtsrvr configuration"; + // + // textComputer + // + this.textComputer.Location = new System.Drawing.Point(136, 40); + this.textComputer.Name = "textComputer"; + this.textComputer.ReadOnly = true; + this.textComputer.Size = new System.Drawing.Size(184, 20); + this.textComputer.TabIndex = 77; + this.textComputer.TabStop = false; + this.textComputer.Text = ""; + // + // textCwd + // + this.textCwd.Location = new System.Drawing.Point(136, 208); + this.textCwd.Name = "textCwd"; + this.textCwd.Size = new System.Drawing.Size(184, 20); + this.textCwd.TabIndex = 5; + this.textCwd.TabStop = false; + this.textCwd.Text = ""; + // + // textArgs + // + this.textArgs.Location = new System.Drawing.Point(136, 184); + this.textArgs.Name = "textArgs"; + this.textArgs.Size = new System.Drawing.Size(184, 20); + this.textArgs.TabIndex = 4; + this.textArgs.TabStop = false; + this.textArgs.Text = ""; + // + // textOther + // + this.textOther.Location = new System.Drawing.Point(136, 160); + this.textOther.Name = "textOther"; + this.textOther.Size = new System.Drawing.Size(184, 20); + this.textOther.TabIndex = 3; + this.textOther.TabStop = false; + this.textOther.Text = ""; + // + // textPath + // + this.textPath.Location = new System.Drawing.Point(136, 112); + this.textPath.Name = "textPath"; + this.textPath.Size = new System.Drawing.Size(184, 20); + this.textPath.TabIndex = 1; + this.textPath.TabStop = false; + this.textPath.Text = ""; + this.textPath.TextChanged += new System.EventHandler(this.textPath_TextChanged); + // + // textDatabase + // + this.textDatabase.Location = new System.Drawing.Point(136, 88); + this.textDatabase.Name = "textDatabase"; + this.textDatabase.ReadOnly = true; + this.textDatabase.Size = new System.Drawing.Size(184, 20); + this.textDatabase.TabIndex = 62; + this.textDatabase.TabStop = false; + this.textDatabase.Text = ""; + // + // textName + // + this.textName.Location = new System.Drawing.Point(136, 64); + this.textName.Name = "textName"; + this.textName.ReadOnly = true; + this.textName.Size = new System.Drawing.Size(184, 20); + this.textName.TabIndex = 60; + this.textName.TabStop = false; + this.textName.Text = ""; + // + // labelCwd + // + this.labelCwd.Location = new System.Drawing.Point(8, 208); + this.labelCwd.Name = "labelCwd"; + this.labelCwd.Size = new System.Drawing.Size(112, 24); + this.labelCwd.TabIndex = 72; + this.labelCwd.Text = "Current working dir.:"; + // + // labelArgs + // + this.labelArgs.Location = new System.Drawing.Point(8, 184); + this.labelArgs.Name = "labelArgs"; + this.labelArgs.Size = new System.Drawing.Size(128, 24); + this.labelArgs.TabIndex = 70; + this.labelArgs.Text = "Arguments to mgmtsrvr:"; + // + // labelOther + // + this.labelOther.Location = new System.Drawing.Point(8, 160); + this.labelOther.Name = "labelOther"; + this.labelOther.Size = new System.Drawing.Size(136, 24); + this.labelOther.TabIndex = 69; + this.labelOther.Text = "Mgmtsrvr port:"; + // + // labelPath + // + this.labelPath.Location = new System.Drawing.Point(8, 112); + this.labelPath.Name = "labelPath"; + this.labelPath.Size = new System.Drawing.Size(128, 24); + this.labelPath.TabIndex = 67; + this.labelPath.Text = "Path to mgmtsrvr binary:"; + // + // label31 + // + this.label31.Location = new System.Drawing.Point(8, 88); + this.label31.Name = "label31"; + this.label31.Size = new System.Drawing.Size(88, 24); + this.label31.TabIndex = 65; + this.label31.Text = "Database:"; + // + // label32 + // + this.label32.Location = new System.Drawing.Point(8, 64); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(88, 24); + this.label32.TabIndex = 63; + this.label32.Text = "Process name:"; + // + // label33 + // + this.label33.Location = new System.Drawing.Point(8, 40); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(64, 24); + this.label33.TabIndex = 61; + this.label33.Text = "Computer:"; + // + // panel5 + // + this.panel5.Controls.AddRange(new System.Windows.Forms.Control[] { + this.radioNo, + this.radioYes, + this.label4}); + this.panel5.Location = new System.Drawing.Point(672, 328); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(344, 312); + this.panel5.TabIndex = 63; + // + // radioNo + // + this.radioNo.Location = new System.Drawing.Point(72, 160); + this.radioNo.Name = "radioNo"; + this.radioNo.Size = new System.Drawing.Size(240, 48); + this.radioNo.TabIndex = 1; + this.radioNo.Text = "I already have a configuration file that I want to use for this configuration."; + this.radioNo.CheckedChanged += new System.EventHandler(this.radioNo_CheckedChanged); + // + // radioYes + // + this.radioYes.Checked = true; + this.radioYes.Location = new System.Drawing.Point(72, 56); + this.radioYes.Name = "radioYes"; + this.radioYes.Size = new System.Drawing.Size(240, 88); + this.radioYes.TabIndex = 0; + this.radioYes.TabStop = true; + this.radioYes.Text = "Generate a configuration file template (initconfig.txt) for the mgmtsrvr based on" + + " the specified configuration? Notepad will be started with a template that you m" + + "ust complete and save in the cwd of the mgmtsrvr."; + this.radioYes.CheckedChanged += new System.EventHandler(this.radioYes_CheckedChanged); + // + // label4 + // + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label4.Location = new System.Drawing.Point(88, 8); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(192, 40); + this.label4.TabIndex = 79; + this.label4.Text = "Tying up the configuration"; + this.label4.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // PanelWizard + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(1030, 755); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.panel5, + this.panel4, + this.panel1, + this.btnFinish, + this.btnNext, + this.btnback, + this.btnCancel, + this.panel6, + this.panel3, + this.panel2}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "PanelWizard"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "Create Database Magician"; + this.Load += new System.EventHandler(this.MDXQueryBuilderWizard_Load); + this.Activated += new System.EventHandler(this.PanelWizard_Activated); + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel6.ResumeLayout(false); + this.panel4.ResumeLayout(false); + this.panel5.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + private void MDXQueryBuilderWizard_Load(object sender, System.EventArgs e) + { + + foreach(Control ct in this.Controls) + { + if(ct.GetType().Name=="Panel") + { + ct.Left=0; + ct.Top=0; + ct.Visible=false; + } + + } + presentPanel=arrayPanel[0]; + //--set the properties + setBtnPanProperty(getPosition(presentPanel)); + //------ + refreshLook(); + } + + //-set the buttons and panel + private void refreshLook() + { + if(cancelEnabled) + btnCancel.Enabled=true; + else + btnCancel.Enabled=false; + + if(backEnabled) + btnback.Enabled=true; + else + btnback.Enabled=false; + + if(nextEnabled) + btnNext.Enabled=true; + else + btnNext.Enabled=false; + + if(finishEnabled) + btnFinish.Enabled=true; + else + btnFinish.Enabled=false; + + if(presentPanel!=null) + { + presentPanel.Show(); + presentPanel.BringToFront(); + } + } + //-------- + private int getPosition(Panel p) + { + int result=-1; + for(int i=0;i<arrayPanel.Length;i++) + { + if(arrayPanel[i]==p) + { + result=i; + break; + } + } + return result ; + } + //---- + + private void setBtnPanProperty(int presentPanelPosition ) + { + int panelLength=arrayPanel.Length-1; + if(presentPanelPosition==0) + { + //first panel...no back ,no finish + cancelEnabled=true; + backEnabled=false; + nextEnabled=false; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=arrayPanel[presentPanelPosition+1]; + backPanel=null; + + } + else if(presentPanelPosition==1) + { + cancelEnabled=true; + backEnabled=true; + nextEnabled=false; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=arrayPanel[presentPanelPosition+1]; + backPanel=arrayPanel[presentPanelPosition-1]; + } + + else if(presentPanelPosition==2) + { + cancelEnabled=true; + backEnabled=true; + nextEnabled=false; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=arrayPanel[presentPanelPosition+1]; + backPanel=arrayPanel[presentPanelPosition-1]; + } + + else if(presentPanelPosition==3) + { + //last panel...no next,finish + cancelEnabled=true; + backEnabled=true; + nextEnabled=true; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=arrayPanel[presentPanelPosition+1]; + backPanel=arrayPanel[presentPanelPosition-1]; + } + else if(presentPanelPosition==4) + { + //last panel...no next,finish + cancelEnabled=true; + backEnabled=true; + nextEnabled=true; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=presentPanel; + backPanel=arrayPanel[presentPanelPosition-1]; + } + + else if(presentPanelPosition==5) + { + //last panel...no next,finish yes + cancelEnabled=true; + backEnabled=true; + nextEnabled=false; + finishEnabled=false; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=null; + backPanel=arrayPanel[presentPanelPosition-1]; + } + + else + { + //no finish,next and back + cancelEnabled=true; + backEnabled=true; + nextEnabled=false; + finishEnabled=true; + presentPanel=arrayPanel[presentPanelPosition]; + nextPanel=null; + backPanel=arrayPanel[presentPanelPosition-1]; + } + } + + private void btnNext_Click(object sender, System.EventArgs e) + { + + if(arrayPanel[getPosition(presentPanel)].Equals(panel1)) + { + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + refreshLook(); + return; + } + if(arrayPanel[getPosition(presentPanel)].Equals(panel2)) + { + m_db.setName(textDbName.Text.ToString()); + m_db.setOwner(textOwner.Text.ToString()); + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + //presentPanel + setBtnPanProperty(getPosition(presentPanel)); + prepareNodeAssignmentPanel(); + refreshLook(); + + return; + } + if(arrayPanel[getPosition(presentPanel)].Equals(panel3)) + { + prepareNodeConfigurationPanel(); + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + refreshLook(); + return; + } + if(arrayPanel[getPosition(presentPanel)].Equals(panel4)) + { + nextEnabled=true; + finishEnabled=true; + backEnabled=true; + cancelEnabled=true; + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + refreshLook(); + return; + } + if(arrayPanel[getPosition(presentPanel)].Equals(panel5)) + { + generateInitConfig(); + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + refreshLook(); + return; + } + + if(arrayPanel[getPosition(presentPanel)].Equals(panel6)) + { + // presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + refreshLook(); + return; + } + /*else + { + presentPanel=arrayPanel[getPosition(presentPanel)+1]; + setBtnPanProperty(getPosition(presentPanel)); + updateListViews(); + refreshLook(); + }*/ + } + + + private void btnback_Click(object sender, System.EventArgs e) + { + presentPanel=arrayPanel[getPosition(presentPanel)-1]; + setBtnPanProperty(getPosition(presentPanel)); + m_noOfConfiguredNodes=0; + m_noOfConfiguredNodes=0; + m_noOfConfiguredMgmt=0; + m_noOfConfiguredNdb=0; + m_noOfConfiguredApi=0; + m_bNdb=false; + m_bMgmt=false; + refreshLook(); + } + + + private void btnCancel_Click(object sender, System.EventArgs e) + { + m_db.removeAllProcesses(); + this.Dispose(true); + } + + + + + private void radioBtnYes_Click(object sender, System.EventArgs e) + { + if(radioBtnNo.Checked.Equals(false)) + { + if(radioBtnYes.Checked.Equals(true)) + radioBtnYes.Checked=false; + else + { + radioBtnYes.Checked=true; + this.btnNext.Enabled=true; + } + + } + if(radioBtnNo.Checked.Equals(true)) + { + radioBtnNo.Checked=false; + radioBtnYes.Checked=true; + buttonComputerAdd.Enabled=false; + this.btnNext.Enabled=true; + } + + } + + private void radioBtnNo_Click(object sender, System.EventArgs e) + { + if(radioBtnYes.Checked.Equals(false)) + { + if(radioBtnNo.Checked.Equals(true)) + { + radioBtnNo.Checked=false; + buttonComputerAdd.Enabled=false; + } + else + { + radioBtnNo.Checked=true; + buttonComputerAdd.Enabled=true; + this.btnNext.Enabled=false; + } + + } + if(radioBtnYes.Checked.Equals(true)) + { + radioBtnYes.Checked=false; + radioBtnNo.Checked=true; + buttonComputerAdd.Enabled=true; + this.btnNext.Enabled=false; + } + } + + private void buttonComputerAdd_Click(object sender, System.EventArgs e) + { + if(getPosition(presentPanel)==0) + { + if(radioBtnNo.Checked.Equals(true)) + { + ComputerAddDialog cad = new ComputerAddDialog(mgmt); + cad.ShowDialog(); + } + } + } + + private void PanelWizard_Activated(object sender, System.EventArgs e) + { + updateComputers(); + } + + private void updateComputers() + { + ArrayList list = mgmt.getComputerCollection(); + this.listBoxComputers.BeginUpdate(); + this.listBoxComputers.Items.Clear(); + foreach(Computer c in list) + { + this.listBoxComputers.Items.Add(c.getName()); + } + if(listBoxComputers.Items.Count > 0) + { + btnNext.Enabled=true; + } + this.listBoxComputers.EndUpdate(); + this.listBoxComputers.Refresh(); + } + + + private void tvComputer_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) + { + tvComputer.SelectedNode.Expand(); + + } + + private void tvComputer_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) + { + + } + + private void tvComputer_MouseLeave(object sender, System.EventArgs e) + { + + } + + private void tvComputer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) + { + TreeNode prevNode = tvComputer.SelectedNode; + if(prevNode!=null) + { + prevNode.BackColor=Color.White; + } + TreeNode node = tvComputer.GetNodeAt(e.X,e.Y); + if(node==null) + { + return; + } + + tvComputer.SelectedNode=node; + tvComputer.SelectedNode.BackColor=Color.LightGray; + + } + + private void btnTransferNodeToComp_Click(object sender, System.EventArgs e) + { + + if(tvComputer.SelectedNode==null) + return; + if(lvNode.SelectedItems.Equals(null)) + return; + int itemCount=lvNode.SelectedItems.Count; + lvNode.BeginUpdate(); + tvComputer.BeginUpdate(); + for(int i=0;i < itemCount;i++) + { + tvComputer.SelectedNode.Nodes.Add(lvNode.SelectedItems[i].Text.ToString()); + } + + for(int i=0;i < itemCount;i++) + { + lvNode.Items.RemoveAt(lvNode.SelectedIndices[0]); + + } + if(lvNode.Items.Count.Equals(0)) + btnNext.Enabled=true; + else + btnNext.Enabled=false; + tvComputer.SelectedNode.Expand(); + lvNode.EndUpdate(); + tvComputer.EndUpdate(); + } + + private void lvNode_SelectedIndexChanged(object sender, System.EventArgs e) + { + } + + private void prepareNodeAssignmentPanel() + { + ArrayList computers = mgmt.getComputerCollection(); + m_nNDB=Convert.ToInt32(comboNDB.SelectedItem.ToString()); + m_nAPI=Convert.ToInt32(comboAPI.SelectedItem.ToString()); + m_nMGM=Convert.ToInt32(comboMGM.SelectedItem.ToString()); + + lvNode.Items.Clear(); + tvComputer.Nodes.Clear(); + for (int i=1;i<=m_nMGM;i++) + lvNode.Items.Add("mgm."+i); + + for (int i=m_nMGM+1;i<=(m_nNDB+m_nMGM);i++) + lvNode.Items.Add("ndb."+i); + + for (int i=m_nMGM+m_nNDB+1;i<=(m_nNDB+m_nMGM+m_nAPI);i++) + lvNode.Items.Add("api."+i); + + foreach(Computer c in computers) + { + if(c.getStatus() == Computer.Status.Connected) + tvComputer.Nodes.Add(c.getName()); + } + + } + private void prepareNodeConfigurationPanel() + { + Computer c; + for(int i=0;i<tvComputer.Nodes.Count;i++) + { + c=mgmt.getComputer(tvComputer.Nodes[i].Text.ToString()); + for(int j=0; j < tvComputer.Nodes[i].Nodes.Count;j++) + { + m_db.addProcess(new Process(tvComputer.Nodes[i].Nodes[j].Text.ToString(),m_db.getOwner(),m_db.getName(),c)); + c.addProcess(m_db.getProcessByName(tvComputer.Nodes[i].Nodes[j].Text.ToString())); + } + } + } + + private void updateListViews() + {/* + lvConfig.Items.Clear(); + ArrayList processes = m_db.getProcesses(); + string [] processcols= new string[5]; + foreach (Process process in processes) + { + processcols[0]=process.getName(); + processcols[1]=process.getComputer().getName(); + processcols[2]=process.getPath(); + processcols[3]=""; + processcols[4]=""; + + ListViewItem lvc= new ListViewItem(processcols); + + + lvConfig.Items.Add(lvc); + } + lvConfig.EndUpdate(); + */ + } + + private void btnConfigure_Click(object sender, System.EventArgs e) + { + + } + + private void textDbName_TextChanged(object sender, System.EventArgs e) + { + if(textOwner.TextLength>0 && textDbName.TextLength > 0) + nextEnabled=true; + else + nextEnabled=false; + + refreshLook(); + + } + + private void checkBoxLater_CheckedChanged(object sender, System.EventArgs e) + { + if(checkBoxLater.Checked.Equals(true)) + { + this.finishEnabled=true; + this.nextEnabled=false; + } + else + { + this.finishEnabled=false; + this.nextEnabled=true; + } + this.refreshLook(); + } + + private void btnFinish_Click(object sender, System.EventArgs e) + { + mgmt.AddDatabase(this.m_db); + + if(radioStartYes.Checked==true) + startDatabase(); + this.Dispose(); + } + + private void panel4_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + + // Point location= new Point(8,40); + // Size s= new Size(panel4.Size.Width-8,panel4.Size.Height-120); + // lvConfig.Location=location; + // lvConfig.Size=s; + + + } + + private void configureMgmt() + { + //clear old + textOther.Text=""; + textArgs.Text=""; + textCwd.Text=""; + textPath.Text=""; + + textPath.Clear(); + textEnv.Clear(); + textOther.Clear(); + textCwd.Clear(); + textArgs.Clear(); + + textPath.ClearUndo(); + textEnv.ClearUndo(); + textOther.ClearUndo(); + textCwd.ClearUndo(); + textArgs.ClearUndo(); + + + textOther.Enabled=true; + textArgs.Enabled=true; + textCwd.Enabled=true; + textPath.Enabled=true; + + textPath.TabStop=true; + textOther.TabStop=true; + textArgs.TabStop=true; + textCwd.TabStop=true; + textEnv.TabStop=true; + + labelTitle.Text="Mgmtsrvr configuration"; + labelPath.Text="Path to mgmtsrvr binary:"; + labelArgs.Text="Arguments to mgmtsrvr:"; + labelOther.Text="Mgmtsrvr port (-p X):"; + + //get new + String process="mgm." + Convert.ToString(m_noOfConfiguredMgmt+1); + Process mgmt=m_db.getProcessByName(process); + textComputer.Text=mgmt.getComputer().getName(); + textName.Text=mgmt.getName().ToString(); + textDatabase.Text=mgmt.getDatabase().ToString(); + m_mgmHost=mgmt.getComputer().getName(); + textPath.Focus(); + } + private void configureApi() + { + checkBoxReuse.Text="Use the same configuration for ALL API nodes?"; + if(m_nAPI > 1) + { + checkBoxReuse.Visible=true; + checkBoxReuse.Enabled=true; + + } + else + { + checkBoxReuse.Enabled=false; + checkBoxReuse.Visible=true; + } + + // clear previous and get a new api + + textOther.Text=""; + textArgs.Text=""; + //textCwd.Text=""; + //textPath.Text=""; + //get new api + textOther.Enabled=false; + textArgs.Enabled=true; + labelTitle.Text="API node configuration"; + labelPath.Text="Path to api binary:"; + labelArgs.Text="Arguments to api:"; + labelOther.Text="NDB_CONNECTSTRING"; + String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1); + Process api=m_db.getProcessByName(process); + textComputer.Text=api.getComputer().getName(); + textName.Text=api.getName().ToString(); + textOther.Text="nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1) + ";host="+this.m_mgmHost + ":" + this.m_mgmPort; + textDatabase.Text=api.getDatabase().ToString(); + textPath.Focus(); + } + + private void configureNdb() + { + + + checkBoxReuse.Text="Use the same configuration for ALL NDB nodes?"; + + + if(this.m_nNDB > 1) + { + checkBoxReuse.Visible=true; + checkBoxReuse.Enabled=true; + + } + else + { + checkBoxReuse.Enabled=false; + checkBoxReuse.Visible=true; + } + + + + labelPath.Text="Path to ndb binary:"; + labelArgs.Text="Arguments to ndb:"; + + // clear previous and get a new ndb + + labelOther.Text="NDB_CONNECTSTRING"; + textArgs.Text="-i"; + textOther.Enabled=false; + textArgs.Enabled=false; + + textPath.TabStop=true; + textEnv.TabStop=true; + textOther.TabStop=false; + textArgs.TabStop=false; + textCwd.TabStop=true; + + //textCwd.Text=""; + //textPath.Text=""; + //get new + + String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1); + textOther.Text="nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1) + ";host="+this.m_mgmHost + ":" + this.m_mgmPort; + Process ndb=m_db.getProcessByName(process); + textComputer.Text=ndb.getComputer().getName(); + textName.Text=ndb.getName().ToString(); + textDatabase.Text=ndb.getDatabase().ToString(); + textPath.Focus(); + } + + + public void saveMgm() + { + String process="mgm." + Convert.ToString(m_noOfConfiguredMgmt+1); + Process mgmt=m_db.getProcessByName(process); + mgmt.setOther(textOther.Text.ToString()); + mgmt.setEnv(textEnv.Text.ToString()); + m_mgmPort = textOther.Text.ToString(); + try + { + m_db.setMgmtPort(Convert.ToInt32(m_mgmPort)); + } + catch(Exception e) + { + MessageBox.Show("Port number must be numeric!!!", "Error",MessageBoxButtons.OK); + this.configureMgmt(); + return; + } + mgmt.setPath(textPath.Text.ToString()); + mgmt.setCwd(textCwd.Text.ToString()); + mgmt.setProcessType("permanent"); + mgmt.setArgs("-i initconfig.txt"); + mgmt.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredMgmt+1)+";host="+m_mgmHost+":" + m_mgmPort); + this.m_noOfConfiguredMgmt++; + } + + public void saveApi() + { + if(checkBoxReuse.Checked) + { + for(;m_noOfConfiguredApi<m_nAPI;m_noOfConfiguredApi++) + { + String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1); + Process api=m_db.getProcessByName(process); + textName.Text=process; + api.setPath(textPath.Text.ToString()); + api.setArgs(textArgs.Text.ToString()); + api.setCwd(textCwd.Text.ToString()); + api.setEnv(textEnv.Text.ToString()); + api.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nNDB+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort); + api.setProcessType("permanent"); + } + + } + else + { + String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1); + Process api=m_db.getProcessByName(process); + api.setPath(textPath.Text.ToString()); + api.setCwd(textCwd.Text.ToString()); + api.setEnv(textEnv.Text.ToString()); + api.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nNDB+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort); + api.setArgs(textArgs.Text.ToString()); + api.setProcessType("permanent"); + this.m_noOfConfiguredApi++; + } + } + + public void saveNdb() + { + + if(checkBoxReuse.Checked) + { + for(;m_noOfConfiguredNdb<m_nNDB;m_noOfConfiguredNdb++) + { + String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1); + Process ndb=m_db.getProcessByName(process); + ndb.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort); + ndb.setPath(textPath.Text.ToString()); + ndb.setArgs(textArgs.Text.ToString()); + ndb.setEnv(textEnv.Text.ToString()); + ndb.setCwd(textCwd.Text.ToString()); + ndb.setProcessType("permanent"); + } + checkBoxReuse.Checked=false; + return; + } + else + { + String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1); + Process ndb=m_db.getProcessByName(process); + ndb.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort); + ndb.setPath(textPath.Text.ToString()); + ndb.setCwd(textCwd.Text.ToString()); + ndb.setArgs(textArgs.Text.ToString()); + ndb.setEnv(textEnv.Text.ToString()); + ndb.setProcessType("permanent"); + m_noOfConfiguredNdb++; + } + + } + + + private void panel5_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + nextEnabled=false; + buttonSave.Enabled=true; + checkBoxReuse.Visible=false; + refreshLook(); + configureMgmt(); + } + + private void buttonSave_Click(object sender, System.EventArgs e) + { + Process p = m_db.getProcessByName(textName.Text.ToString()); + + if(textOther.Text.ToString().Equals("")) + { + if(textName.Text.StartsWith("mgm")) + { + MessageBox.Show("You have to specify a port.","Warning",MessageBoxButtons.OK); + return; + } + if(textName.Text.StartsWith("ndb")) + { + MessageBox.Show("You have to specify a filesystem path.","Warning",MessageBoxButtons.OK); + return; + } + + } + + if(textPath.Text.ToString().Equals("")) + { + if(textName.Text.StartsWith("mgm")) + { + MessageBox.Show("You have to specify the path to the mgmtsrvr.","Warning",MessageBoxButtons.OK); + return; + } + if(textName.Text.StartsWith("ndb")) + { + MessageBox.Show("You have to specify the path to ndb.","Warning",MessageBoxButtons.OK); + return; + } + } + + if(textArgs.Text.ToString().Equals("")) + { + if(textName.Text.StartsWith("mgm")) + { + MessageBox.Show("You have to specify the arguments to the mgmtsrvr.","Warning",MessageBoxButtons.OK); + return; + } + } + + if(textCwd.Text.ToString().Equals("")) + { + if(textCwd.Text.StartsWith("mgm")) + { + MessageBox.Show("You have to specify the current working directory for the mgmtsrvr.","Warning",MessageBoxButtons.OK); + return; + } + } + + + /* + * INPUT IS FINE AT THIS POINT + * Everything needed for respective process is ok + * */ + + if(textName.Text.StartsWith("mgm")) + { + //MessageBox.Show(textOther.Text.ToString()); + saveMgm(); + + } + + if(textName.Text.StartsWith("ndb")) + { + saveNdb(); + + } + + if(textName.Text.StartsWith("api")) + { + saveApi(); + + } + + if(m_noOfConfiguredMgmt < m_nMGM) + { + //load another Mgmt + labelTitle.Text="Mgmtsrvr configuration"; + configureMgmt(); + } + else + { + m_bMgmt=true; + } + + if(m_bMgmt) + { + labelTitle.Text="NDB node configuration"; + if(m_noOfConfiguredNdb < m_nNDB) + { + configureNdb(); + } + else + m_bNdb=true; + } + + if(m_bNdb && m_bMgmt) + { + labelTitle.Text="API node configuration"; + if(m_noOfConfiguredApi < m_nAPI) + configureApi(); + else + { + nextEnabled=true; + buttonSave.Enabled=false; + refreshLook(); + } + } + + } + + private void listBoxComputers_SelectedIndexChanged(object sender, System.EventArgs e) + { + + } + + private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + updateComputers(); + } + + private void radioYes_CheckedChanged(object sender, System.EventArgs e) + { + if(radioYes.Checked==true) + { + radioNo.Checked=false; + } + if(radioYes.Checked==false) + { + radioNo.Checked=true; + } + + } + + private void radioNo_CheckedChanged(object sender, System.EventArgs e) + { + if(radioNo.Checked==true) + { + radioYes.Checked=false; + } + if(radioNo.Checked==false) + { + radioYes.Checked=true; + } + } + + private void radioStartYes_CheckedChanged(object sender, System.EventArgs e) + { + + if(radioStartYes.Checked==true) + { + radioStartNo.Checked=false; + } + if(radioStartYes.Checked==false) + { + radioStartNo.Checked=true; + } + finishEnabled=true; + refreshLook(); + } + + private void radioStartNo_CheckedChanged(object sender, System.EventArgs e) + { + if(radioStartNo.Checked==true) + { + radioStartYes.Checked=false; + } + if(radioStartNo.Checked==false) + { + radioStartYes.Checked=true; + } + finishEnabled=true; + refreshLook(); + } + + + + + public void startDatabase() + { + startDatabaseDlg x = new startDatabaseDlg(this.m_db); + + + x.ShowDialog(); + + + } + + + public void generateInitConfig() + { + MessageBox.Show("Generate initconfig.txt"); + } + + private void label11_Click(object sender, System.EventArgs e) + { + + } + + private void textOwner_TextChanged(object sender, System.EventArgs e) + { + if(textDbName.TextLength > 0 && textOwner.TextLength > 0) + nextEnabled=true; + else + nextEnabled=false; + + refreshLook(); + } + + private void panel2_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + textOwner.Text=System.Environment.UserName; + this.Validate(); + if(textDbName.TextLength > 0 && textOwner.TextLength>0) + { + nextEnabled=true; + } + else + { + nextEnabled=false; + } + refreshLook(); + } + + private void textPath_TextChanged(object sender, System.EventArgs e) + { + try + { + + } + catch (Exception exc) + { + MessageBox.Show(exc.ToString()); + } + } + + private void panel2_Validating(object sender, System.ComponentModel.CancelEventArgs e) + { + if(textOwner.TextLength>0 && textDbName.TextLength > 0) + nextEnabled=true; + else + nextEnabled=false; + } + + + + + + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs new file mode 100644 index 00000000000..eac12d4868e --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs @@ -0,0 +1,159 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for Process. + /// </summary> + public class Process + { + public enum Status {Running, Stopped, Unknown} + private string m_id; + protected string m_name; + private Status m_status; + private Computer m_computer; + private string m_owner; + private string m_cwd; + private string m_type; + private string m_path; + private string m_other; + private string m_args; + private string m_env; + private string m_database; + private string m_connectString; + private bool m_defined; + public Process( string name, + string owner, string database, + Computer computer) + { + m_name=name; + m_owner=owner; + m_computer=computer; + m_status=Status.Unknown; + m_database=database; + m_defined=false; + m_path=""; + m_cwd=""; + m_args=""; + m_other=""; + } + public Process() + { + + } + public Process(string id) + { + m_id=id; + } + + public Process( string name, + string database, + Computer computer) + { + m_name=name; + m_computer=computer; + m_status=Status.Unknown; + m_database=database; + m_defined=false; + } + + public Process( string name, + Computer computer) + { + m_name=name; + m_computer=computer; + m_status=Status.Unknown; + m_defined=false; + } + + + public string getStatusString() + { + if(m_status.Equals(Status.Running)) + return "Running"; + if(m_status.Equals(Status.Stopped)) + return "Stopped"; + return "Unknown"; + } + + public Computer getComputer() {return m_computer;} + public string getName() {return m_name;} + public string getDatabase() {return m_database;} + public string getOwner() {return m_owner;} + public string getId() {return m_id;} + public void setId(string id) {m_id=id;} + + public void setCwd(string cwd) {m_cwd=cwd;} + public void setPath(string path) {m_path=path;} + public void setArgs(string args) {m_args=args;} + public void setOther(string other) {m_other=other;} + public void setEnv(string env) {m_env=env;} + public void setName(string name) {m_name=name;} + public void setOwner(string owner) {m_owner=owner;} + public void setDatabase(string db) {m_database=db;} + public void setComputer(Computer c) {m_computer=c;} + + + public string getCwd() {return m_cwd;} + public string getPath() {return m_path;} + public string getArgs() {return m_args;} + public string getOther() {return m_other;} + public string getEnv() {return m_env;} + + public bool isDefined() {return m_defined;} + public void setDefined(bool defined) + { + m_defined=defined; + } + + public Status getStatus() + { + return m_status; + } + + public void setConnectString(string cs) + { + m_connectString=cs; + } + + public string getConnectString() + { + return m_connectString; + } + public void setStatus(Status status) + { + m_status=status; + } + + + public void setProcessType(string type) + { + m_type=type; + } + public string getProcessType() + { + return m_type; + } + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs new file mode 100644 index 00000000000..ab8d58ed11f --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs @@ -0,0 +1,450 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for ProcessDefineDialog. + /// </summary> + public class ProcessDefineDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.ComboBox comboComputer; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox textProcessName; + private System.Windows.Forms.TextBox textProcessGroup; + private System.Windows.Forms.TextBox textProcessEnv; + private System.Windows.Forms.TextBox textProcessPath; + private System.Windows.Forms.TextBox textProcessArgs; + private System.Windows.Forms.TextBox textProcessCWD; + private System.Windows.Forms.TextBox textProcessOwner; + private System.Windows.Forms.ComboBox comboType; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnCancel; + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.Container components = null; + private ComputerMgmt c_mgmt; + private string m_selComputer; + public ProcessDefineDialog(ComputerMgmt mgmt, string computer) + { + + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + m_selComputer =computer; //the selected computer in the TreeView + c_mgmt=mgmt; + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.comboComputer = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.textProcessName = new System.Windows.Forms.TextBox(); + this.textProcessGroup = new System.Windows.Forms.TextBox(); + this.textProcessEnv = new System.Windows.Forms.TextBox(); + this.textProcessPath = new System.Windows.Forms.TextBox(); + this.textProcessArgs = new System.Windows.Forms.TextBox(); + this.textProcessCWD = new System.Windows.Forms.TextBox(); + this.textProcessOwner = new System.Windows.Forms.TextBox(); + this.comboType = new System.Windows.Forms.ComboBox(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.label18 = new System.Windows.Forms.Label(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboComputer + // + this.comboComputer.ItemHeight = 13; + this.comboComputer.Location = new System.Drawing.Point(152, 24); + this.comboComputer.Name = "comboComputer"; + this.comboComputer.Size = new System.Drawing.Size(112, 21); + this.comboComputer.TabIndex = 0; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(24, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(64, 24); + this.label1.TabIndex = 1; + this.label1.Text = "Computer:"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(24, 48); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(88, 24); + this.label2.TabIndex = 2; + this.label2.Text = "Process name:"; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(24, 72); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(88, 24); + this.label3.TabIndex = 3; + this.label3.Text = "Group:"; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(24, 96); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(88, 24); + this.label4.TabIndex = 4; + this.label4.Text = "Env. variables:"; + // + // label5 + // + this.label5.Location = new System.Drawing.Point(24, 120); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(88, 24); + this.label5.TabIndex = 5; + this.label5.Text = "Path to binary:"; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(24, 144); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(112, 24); + this.label6.TabIndex = 6; + this.label6.Text = "Arguments to binary:"; + // + // label7 + // + this.label7.Location = new System.Drawing.Point(24, 168); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(112, 24); + this.label7.TabIndex = 7; + this.label7.Text = "Type of process:"; + // + // label8 + // + this.label8.Location = new System.Drawing.Point(24, 192); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(112, 24); + this.label8.TabIndex = 8; + this.label8.Text = "Current working dir.:"; + // + // label9 + // + this.label9.Location = new System.Drawing.Point(24, 216); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(112, 24); + this.label9.TabIndex = 9; + this.label9.Text = "Owner:"; + // + // textProcessName + // + this.textProcessName.Location = new System.Drawing.Point(152, 48); + this.textProcessName.Name = "textProcessName"; + this.textProcessName.Size = new System.Drawing.Size(112, 20); + this.textProcessName.TabIndex = 1; + this.textProcessName.Text = ""; + // + // textProcessGroup + // + this.textProcessGroup.Location = new System.Drawing.Point(152, 72); + this.textProcessGroup.Name = "textProcessGroup"; + this.textProcessGroup.Size = new System.Drawing.Size(112, 20); + this.textProcessGroup.TabIndex = 2; + this.textProcessGroup.Text = ""; + // + // textProcessEnv + // + this.textProcessEnv.Location = new System.Drawing.Point(152, 96); + this.textProcessEnv.Name = "textProcessEnv"; + this.textProcessEnv.Size = new System.Drawing.Size(112, 20); + this.textProcessEnv.TabIndex = 3; + this.textProcessEnv.Text = ""; + // + // textProcessPath + // + this.textProcessPath.Location = new System.Drawing.Point(152, 120); + this.textProcessPath.Name = "textProcessPath"; + this.textProcessPath.Size = new System.Drawing.Size(112, 20); + this.textProcessPath.TabIndex = 4; + this.textProcessPath.Text = ""; + // + // textProcessArgs + // + this.textProcessArgs.Location = new System.Drawing.Point(152, 144); + this.textProcessArgs.Name = "textProcessArgs"; + this.textProcessArgs.Size = new System.Drawing.Size(112, 20); + this.textProcessArgs.TabIndex = 5; + this.textProcessArgs.Text = ""; + // + // textProcessCWD + // + this.textProcessCWD.Location = new System.Drawing.Point(152, 192); + this.textProcessCWD.Name = "textProcessCWD"; + this.textProcessCWD.Size = new System.Drawing.Size(112, 20); + this.textProcessCWD.TabIndex = 7; + this.textProcessCWD.Text = ""; + // + // textProcessOwner + // + this.textProcessOwner.Location = new System.Drawing.Point(152, 216); + this.textProcessOwner.Name = "textProcessOwner"; + this.textProcessOwner.Size = new System.Drawing.Size(112, 20); + this.textProcessOwner.TabIndex = 8; + this.textProcessOwner.Text = ""; + // + // comboType + // + this.comboType.ItemHeight = 13; + this.comboType.Items.AddRange(new object[] { + "Permanent", + "Interactive"}); + this.comboType.Location = new System.Drawing.Point(152, 168); + this.comboType.Name = "comboType"; + this.comboType.Size = new System.Drawing.Size(112, 21); + this.comboType.TabIndex = 6; + // + // label10 + // + this.label10.Location = new System.Drawing.Point(272, 32); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(88, 16); + this.label10.TabIndex = 19; + this.label10.Text = "(Mandatory)"; + // + // label11 + // + this.label11.Location = new System.Drawing.Point(272, 56); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(88, 16); + this.label11.TabIndex = 20; + this.label11.Text = "(Mandatory)"; + // + // label12 + // + this.label12.Location = new System.Drawing.Point(272, 80); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(88, 16); + this.label12.TabIndex = 21; + this.label12.Text = "(Mandatory)"; + // + // label13 + // + this.label13.Location = new System.Drawing.Point(272, 127); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(88, 16); + this.label13.TabIndex = 22; + this.label13.Text = "(Mandatory)"; + // + // label15 + // + this.label15.Location = new System.Drawing.Point(272, 176); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(88, 16); + this.label15.TabIndex = 24; + this.label15.Text = "(Mandatory)"; + // + // label16 + // + this.label16.Location = new System.Drawing.Point(272, 200); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(88, 16); + this.label16.TabIndex = 25; + this.label16.Text = "(Mandatory)"; + // + // label14 + // + this.label14.Location = new System.Drawing.Point(272, 224); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(88, 16); + this.label14.TabIndex = 26; + this.label14.Text = "(Mandatory)"; + // + // label17 + // + this.label17.Location = new System.Drawing.Point(272, 104); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(88, 16); + this.label17.TabIndex = 27; + this.label17.Text = "(Optional)"; + // + // label18 + // + this.label18.Location = new System.Drawing.Point(272, 152); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(88, 16); + this.label18.TabIndex = 28; + this.label18.Text = "(Optional)"; + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(288, 248); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.TabIndex = 9; + this.btnAdd.Text = "Define..."; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(152, 248); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.TabIndex = 10; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // ProcessDefineDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(370, 279); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.btnCancel, + this.btnAdd, + this.label18, + this.label17, + this.label14, + this.label16, + this.label15, + this.label13, + this.label12, + this.label11, + this.label10, + this.comboType, + this.textProcessOwner, + this.textProcessCWD, + this.textProcessArgs, + this.textProcessPath, + this.textProcessEnv, + this.textProcessGroup, + this.textProcessName, + this.label9, + this.label8, + this.label7, + this.label6, + this.label5, + this.label4, + this.label3, + this.label2, + this.label1, + this.comboComputer}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProcessDefineDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Define Process"; + this.Load += new System.EventHandler(this.ProcessDefineDialog_Load); + this.ResumeLayout(false); + + } + #endregion + + private void btnCancel_Click(object sender, System.EventArgs e) + { + this.Dispose(); + this.Close(); + } + + private void btnAdd_Click(object sender, System.EventArgs e) + { + //TODO: ERROR CHECK + + Computer c; + c=c_mgmt.getComputer(this.m_selComputer); + + c.addProcess(new Process(this.textProcessName.Text.ToString(), + this.textProcessOwner.Text.ToString(), + this.textProcessGroup.Text.ToString(), + c)); + this.Close(); + this.Dispose(); + } + + private void ProcessDefineDialog_Load(object sender, System.EventArgs e) + { + comboType.SelectedIndex=0; + ArrayList list = c_mgmt.getComputerCollection(); + int i=0, selIndex=0; + foreach(Computer computer in list) + { + this.comboComputer.Items.Add(computer.getName()); + if(computer.getName().Equals(m_selComputer)) + selIndex=i; + i++; + } + comboComputer.SelectedIndex=selIndex; + } + + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs new file mode 100644 index 00000000000..41929c104d0 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs @@ -0,0 +1,56 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Text; +using System.Collections.Specialized; +using System.IO; +using System.Windows.Forms; +namespace NDB_CPC.fileaccess +{ + /// <summary> + /// Summary description for FileMgmt. + /// </summary> + public class FileMgmt + { + public FileMgmt() + { + } + + public StringCollection importHostFile(string filename) + { + StringCollection sc = new StringCollection(); + StreamReader SR = new StreamReader(filename); + string line =""; + line = SR.ReadLine(); + while(!line.Equals("")) + { + sc.Add(line); + line = SR.ReadLine(); + } + return sc; + } + + public void exportHostFile(string filename, string content) + { + StreamWriter SW = new StreamWriter(filename,false); + SW.Write(content); + SW.WriteLine(""); + SW.WriteLine(""); + SW.Close(); + } + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs new file mode 100644 index 00000000000..6e070875b25 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs @@ -0,0 +1,375 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Collections; +using System.IO; +using System.Windows.Forms; +using NDB_CPC; +using NDB_CPC.socketcomm; + +namespace NDB_CPC.simpleparser +{ + /// <summary> + /// Summary description for SimpleCPCParser. + /// </summary> + public class SimpleCPCParser + { + public SimpleCPCParser() + { + // + // TODO: Add constructor logic here + // + } + + public static void parse(Process p, SocketComm comm) + { + + string line=comm.readLine();//reader.ReadLine(); + while(line.Equals("")) + { + line=comm.readLine(); + } + if(line.Equals("define process")) + { + defineProcess(p, comm); + line=""; + return; + } + if(line.Equals("start process")) + { + startProcess(p,comm); + line=""; + return; + } + if(line.Equals("stop process")) + { + stopProcess(p,comm); + line=""; + return; + } + if(line.Equals("undefine process")) + { + undefineProcess(p,comm); + line=""; + return; + } + + } + + public static void parse(ArrayList processes, Computer c, SocketComm comm) + { + + string line=comm.readLine();//reader.ReadLine(); + while(line.Equals("")) + { + line=comm.readLine(); + } + + if(line.Equals("start processes")) + { + listProcesses(processes, c, comm); + line=""; + return; + } + + } + + private static void defineProcess(Process p, SocketComm comm) + { + string line=comm.readLine();//reader.ReadLine(); + while(!line.Equals("")) + { + if(line.StartsWith("status:")) + { + line=line.Remove(0,7); + line=line.Trim(); + if(line.Equals("1")) + { + p.setDefined(true); + p.setStatus(Process.Status.Stopped); + } + else + p.setDefined(false); + } + if(line.StartsWith("id:")) + { + line=line.Remove(0,3); + line=line.Trim(); + p.setId(line); + } + line=comm.readLine(); + } + } + + + private static void startProcess(Process p, SocketComm comm) + { + string line=comm.readLine();//reader.ReadLine(); + while(!line.Equals("")) + { + if(line.StartsWith("status:")) + { + line=line.Remove(0,7); + line=line.Trim(); + if(line.Equals("1")) + p.setStatus(NDB_CPC.Process.Status.Running); + else + p.setStatus(NDB_CPC.Process.Status.Unknown); + + } + if(line.StartsWith("id:")) + { + line=line.Remove(0,3); + line=line.Trim(); + if(p.getId().Equals(line)) + { + ; + } + else + { + //damn something is wrong + p.setStatus(NDB_CPC.Process.Status.Unknown); + } + + } + line=comm.readLine(); + } + } + private static void undefineProcess(Process p, SocketComm comm) + { + string line=comm.readLine();//reader.ReadLine(); + while(!line.Equals("")) + { + if(line.StartsWith("status:")) + { + + line=line.Remove(0,7); + line=line.Trim(); + if(line.Equals("1")) + p.setDefined(false); + else + p.setDefined(true); + + } + if(line.StartsWith("id:")) + { + line=line.Remove(0,3); + line=line.Trim(); + } + line=comm.readLine(); + } + } + + private static void stopProcess(Process p, SocketComm comm) + { + string line=comm.readLine();//reader.ReadLine(); + while(!line.Equals("")) + { + if(line.StartsWith("status:")) + { + line=line.Remove(0,7); + line=line.Trim(); + if(line.Equals("1")) + p.setStatus(NDB_CPC.Process.Status.Stopped); + else + p.setStatus(NDB_CPC.Process.Status.Unknown); + + } + if(line.StartsWith("id:")) + { + line=line.Remove(0,3); + line=line.Trim(); + if(p.getId().Equals(line)) + { + ; + } + else + { + //damn something is wrong + p.setStatus(NDB_CPC.Process.Status.Unknown); + } + + } + line=comm.readLine(); + } + } + private static void listProcesses(ArrayList processes, Computer c, SocketComm comm) + { + bool processExist = false; + + string line=comm.readLine();//reader.ReadLine(); + while(!line.Equals("end processes")) + { + if(line.Equals("process")) + { + line=comm.readLine(); + Process p = new Process(); + + while(!line.Equals("")) + { + if(line.StartsWith("id:")) + { + string pid; + line=line.Remove(0,3); + pid=line.Trim(); + /*check if process already exist*/ + processExist=findProcess(processes,pid); + if(!processExist) + { + p.setId(pid); + } + } + + if(line.StartsWith("name:")) + { + + line=line.Remove(0,5); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setName(line); + } + } + + if(line.StartsWith("path:")) + { + + line=line.Remove(0,5); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setPath(line); + } + } + + if(line.StartsWith("args:")) + { + + line=line.Remove(0,5); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setArgs(line); + } + } + + if(line.StartsWith("type:")) + { + + line=line.Remove(0,5); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + + } + } + + if(line.StartsWith("cwd:")) + { + + line=line.Remove(0,4); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setCwd(line); + } + } + + if(line.StartsWith("env:")) + { + + line=line.Remove(0,4); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setEnv(line); + } + } + + if(line.StartsWith("owner:")) + { + + line=line.Remove(0,6); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setOwner(line); + } + } + if(line.StartsWith("group:")) + { + + line=line.Remove(0,6); + line=line.Trim(); + /*check if process already exist*/ + if(!processExist) + { + p.setDatabase(line); + } + } + + if(line.StartsWith("status:")) + { + + line=line.Remove(0,7); + line=line.Trim(); + /*check if process already exist*/ + //if(!processExist) + //{ + if(line.Equals("0")) + p.setStatus(Process.Status.Stopped); + if(line.Equals("1")) + p.setStatus(Process.Status.Running); + if(line.Equals("2")) + p.setStatus(Process.Status.Unknown); + //} + } + + + line=comm.readLine(); + } + if(!processExist) + { + p.setComputer(c); + p.setDefined(true); + processes.Add(p); + } + processExist=false; + } + line=comm.readLine(); + + } + } + + private static bool findProcess(ArrayList processes, string pid) + { + foreach (Process p in processes) + { + if(p.getId().Equals(pid)) + return true; + } + return false; + + } + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs new file mode 100644 index 00000000000..9025f122994 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs @@ -0,0 +1,222 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Windows.Forms; +using System.Threading; +using System.IO; + +namespace NDB_CPC.socketcomm +{ + /// <summary> + /// Summary description for SocketComm. + /// </summary> + public class SocketComm + { + private myTcpClient sender; + private StreamWriter writer; + private StreamReader reader; + private string m_host; + private int m_port; + private bool m_connected; + private bool m_connecting; + private Thread connectThread; + public SocketComm(string host, int port) + { + + m_host=host; + m_port=port; + m_connected=false; + m_connecting=false; + } + + + + public bool isConnected() + { + return m_connected; + } + + public void doConnect() + { + if(!m_connecting && !m_connected) + { + connectThread= new Thread(new ThreadStart(connect)); + connectThread.Start(); + } + + } + + private void connect() + { + m_connecting=true; + while(true) + { + if(!m_connected) + { + try + { + // Establish the remote endpoint for the socket. + // The name of the + // remote device is "host.contoso.com". + + // Create a TCP/IP socket. + sender = new myTcpClient(); + // Connect the socket to the remote endpoint. Catch any errors. + try + { + /* + IPAddress ipAddress = Dns.Resolve(host).AddressList[0]; + IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000); +*/ + + + sender.Connect(m_host,m_port);; + + writer = new StreamWriter(sender.GetStream(), Encoding.ASCII); + reader = new StreamReader(sender.GetStream(), Encoding.ASCII); + m_connected=true; + m_connecting=false; + // break; + Console.WriteLine("Socket connected to {0}", + sender.ToString()); + + } + catch (ArgumentNullException ane) + { + Console.WriteLine("ArgumentNullException : {0}",ane.ToString()); + m_connected=false; + } + catch (SocketException se) + { + Console.WriteLine("SocketException : {0}",se.ToString()); + m_connected=false; + } + } + catch (Exception e) + { + Console.WriteLine("Unexpected exception : {0}", e.ToString()); + m_connected=false; + } + + } + + Thread.Sleep(200); + } + } + + public bool disconnect() + { + try + { + this.m_connected=false; + this.m_connecting=false; + sender.GetUnderlyingSocket().Shutdown(SocketShutdown.Both); + sender.GetUnderlyingSocket().Close(); + writer.Close(); + reader.Close(); + sender.Close(); + + } + catch (ArgumentNullException ane) + { + Console.WriteLine("ArgumentNullException : {0}",ane.ToString()); + connectThread.Abort(); + return false; + } + catch (SocketException se) + { + Console.WriteLine("SocketException : {0}",se.ToString()); + connectThread.Abort(); + return false; + } + catch (Exception e) + { + Console.WriteLine("Unexpected exception : {0}", e.ToString()); + connectThread.Abort(); + return false; + } + connectThread.Abort(); + return true; + } + + public bool writeMessage(string message) + { + int attempts=0; + while (attempts < 10) + { + try + { + writer.WriteLine(message); + writer.Flush(); + message=""; + return true; + } + catch(IOException e) + { + this.disconnect(); + this.doConnect(); + Thread.Sleep(200); + attempts++; + } + catch(System.NullReferenceException) + { + this.disconnect(); + this.doConnect(); + + Thread.Sleep(200); + attempts++; + } + } + return false; + } + + public string readLine() + { + int attempts=0; + string line=""; + while (attempts < 10){ + try + { + line = reader.ReadLine(); + if(line==null) + line=""; + return line; + } + catch(IOException e) + { + this.disconnect(); + this.doConnect(); + Thread.Sleep(400); + attempts++; + } + catch(System.NullReferenceException) + { + this.disconnect(); + this.doConnect(); + Thread.Sleep(400); + attempts++; + } + } + return ""; + + } + + } +} + diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs new file mode 100644 index 00000000000..25d0d9947d6 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.IO; + + +namespace NDB_CPC.socketcomm +{ + public class myTcpClient : TcpClient + { + private Socket s; + public myTcpClient(): base() + { + if(this.Active) + { + s = this.Client; + } + } + public Socket GetUnderlyingSocket() + { + return s; + } + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs new file mode 100644 index 00000000000..4261efc8a29 --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs @@ -0,0 +1,266 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using NDB_CPC.simpleparser; + +namespace NDB_CPC +{ + /// <summary> + /// Summary description for startDatabase. + /// </summary> + public class startDatabaseDlg : System.Windows.Forms.Form + { + private System.Windows.Forms.TextBox textAction; + private System.Windows.Forms.Label label1; + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.Container components = null; + private System.Windows.Forms.ProgressBar progressBar; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button buttonGo; + private Database m_db; + public startDatabaseDlg(Database db) + { + + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + m_db=db; + } + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.textAction = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.label2 = new System.Windows.Forms.Label(); + this.buttonGo = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textAction + // + this.textAction.Location = new System.Drawing.Point(104, 40); + this.textAction.Name = "textAction"; + this.textAction.ReadOnly = true; + this.textAction.Size = new System.Drawing.Size(256, 20); + this.textAction.TabIndex = 0; + this.textAction.Text = ""; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(8, 40); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(96, 16); + this.label1.TabIndex = 1; + this.label1.Text = "Current activity:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(104, 88); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(152, 16); + this.progressBar.TabIndex = 2; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(8, 88); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(96, 16); + this.label2.TabIndex = 3; + this.label2.Text = "Activity progress:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // buttonGo + // + this.buttonGo.Location = new System.Drawing.Point(152, 136); + this.buttonGo.Name = "buttonGo"; + this.buttonGo.Size = new System.Drawing.Size(96, 24); + this.buttonGo.TabIndex = 4; + this.buttonGo.Text = "Go!"; + this.buttonGo.Click += new System.EventHandler(this.buttonGo_Click); + // + // startDatabaseDlg + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(378, 167); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.buttonGo, + this.label2, + this.progressBar, + this.label1, + this.textAction}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "startDatabaseDlg"; + this.Text = "Starting database"; + this.Load += new System.EventHandler(this.startDatabase_Load); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.startDatabase_Paint); + this.ResumeLayout(false); + + } + #endregion + + private void startDatabase_Load(object sender, System.EventArgs e) + { + + } + + private void startDatabase_Paint(object sender, System.Windows.Forms.PaintEventArgs e) + { + + + + } + private void defineProcesses() + { + ArrayList processes = m_db.getProcesses(); + progressBar.Maximum = processes.Count; + progressBar.Minimum = 0; + + int retry=0; + //sc.connect("130.100.232.7"); + foreach (Process p in processes) + { + Computer comp; + retry=0; + //if(p.getName().StartsWith("ndb") || p.getName().StartsWith("mgm")) + //{ + textAction.Text="Defining process " + p.getName(); + textAction.Refresh(); + comp=p.getComputer(); + while(retry<10) + { + if(!comp.isConnected()) + { + comp.connectToCpcd(); + + } + else + { + if(comp.defineProcess(p)<0) + { + ; + } + else + break; + } + if(retry==9) + { + if(MessageBox.Show(this,"Failed to define process. Try again?","Warning!!!",MessageBoxButtons.YesNo)==DialogResult.Yes) + retry=0; + } + retry++; + //comp.undefineProcess(p); + } + //} + progressBar.PerformStep(); + } + } + + private void startProcesses() + { + + ArrayList processes = m_db.getProcesses(); + progressBar.Maximum = processes.Count; + progressBar.Minimum = 0; + string start = "start process \n"; + + int retry=0; + //sc.connect("130.100.232.7"); + foreach (Process p in processes) + { + Computer comp; + if((p.getName().StartsWith("ndb")) || (p.getName().StartsWith("mgm"))) + { + textAction.Text="Starting process " + p.getName(); + textAction.Refresh(); + start = start + "id:" + p.getId() + "\n\n"; + comp=p.getComputer(); + while(retry<10) + { + if(!comp.isConnected()) + { + comp.connectToCpcd(); + } + else + { + if(comp.startProcess(p)<0) + { + ; + } + else + break; + } + if(retry==9) + { + if(MessageBox.Show(this,"Failed to start process. Retry again?","Warning!!!",MessageBoxButtons.YesNo)==DialogResult.Yes) + retry=0; + } + + retry++; + } + } + progressBar.PerformStep(); + + } + + } + + private void buttonGo_Click(object sender, System.EventArgs e) + { + buttonGo.Enabled=false; + progressBar.Step=1; + defineProcesses(); + progressBar.Value=0; + startProcesses(); + + } + + + } +} diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs new file mode 100644 index 00000000000..5258ad290fc --- /dev/null +++ b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs @@ -0,0 +1,423 @@ +/* Copyright (C) 2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.IO; +using System.Threading ; + +namespace NDB_CPC.telnetclient +{ + /// <summary> + /// Summary description for telnetClient. + /// </summary> + public class telnetClient + { + Char IAC = Convert.ToChar(255); + Char DO = Convert.ToChar(253); + Char DONT = Convert.ToChar(254); + Char WILL = Convert.ToChar(251); + Char WONT = Convert.ToChar(252); + Char SB = Convert.ToChar(250); + Char SE = Convert.ToChar(240); + const Char IS = '0'; + const Char SEND = '1'; + const Char INFO = '2'; + const Char VAR = '0'; + const Char VALUE = '1'; + const Char ESC = '2'; + const Char USERVAR = '3'; + string m_strResp; + + private ArrayList m_ListOptions = new ArrayList(); + private IPEndPoint iep ; + private AsyncCallback callbackProc ; + private string address ; + private int port ; + private Socket s ; + private TextBox textBox1; + Byte[] m_byBuff = new Byte[32767]; + + + public telnetClient(string ip, int p, TextBox tb) + { + + address = ip; + port = p; + textBox1=tb; + IPHostEntry IPHost = Dns.Resolve(address); + string []aliases = IPHost.Aliases; + IPAddress[] addr = IPHost.AddressList; + + try + { + // Create New Socket + s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + // Create New EndPoint + iep = new IPEndPoint(addr[0],port); + // This is a non blocking IO + s.Blocking = false ; + // Assign Callback function to read from Asyncronous Socket + callbackProc = new AsyncCallback(ConnectCallback); + // Begin Asyncronous Connection + s.BeginConnect(iep , callbackProc, s ) ; + + } + catch(Exception eeeee ) + { + MessageBox.Show(eeeee.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop ); + Application.Exit(); + } + } + + public void ConnectCallback( IAsyncResult ar ) + { + try + { + // Get The connection socket from the callback + Socket sock1 = (Socket)ar.AsyncState; + if ( sock1.Connected ) + { + // Define a new Callback to read the data + AsyncCallback recieveData = new AsyncCallback( OnRecievedData ); + // Begin reading data asyncronously + sock1.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData , sock1 ); + } + } + catch( Exception ex ) + { + MessageBox.Show(ex.Message, "Setup Recieve callbackProc failed!" ); + } + } + + + public void OnRecievedData( IAsyncResult ar ) + { + // Get The connection socket from the callback + Socket sock = (Socket)ar.AsyncState; + // Get The data , if any + int nBytesRec = sock.EndReceive( ar ); + if( nBytesRec > 0 ) + { + string sRecieved = Encoding.ASCII.GetString( m_byBuff, 0, nBytesRec ); + string m_strLine=""; + for ( int i=0; i < nBytesRec;i++) + { + Char ch = Convert.ToChar(m_byBuff[i]); + switch( ch ) + { + case '\r': + m_strLine += Convert.ToString("\r\n"); + break; + case '\n': + break; + default: + m_strLine += Convert.ToString(ch); + break; + } + } + try + { + int strLinelen = m_strLine.Length ; + if ( strLinelen == 0 ) + { + m_strLine = Convert.ToString("\r\n"); + } + + Byte[] mToProcess = new Byte[strLinelen]; + for ( int i=0; i < strLinelen ; i++) + mToProcess[i] = Convert.ToByte(m_strLine[i]); + // Process the incoming data + string mOutText = ProcessOptions(mToProcess); + if ( mOutText != "" ) + textBox1.AppendText(mOutText); + + // Respond to any incoming commands + RespondToOptions(); + } + catch( Exception ex ) + { + Object x = this ; + MessageBox.Show(ex.Message , "Information!" ); + } + } + else + { + // If no data was recieved then the connection is probably dead + Console.WriteLine( "Disconnected", sock.RemoteEndPoint ); + sock.Shutdown( SocketShutdown.Both ); + sock.Close(); + Application.Exit(); + } + } + + private string ProcessOptions(byte[] m_strLineToProcess) + { + string m_DISPLAYTEXT =""; + string m_strTemp ="" ; + string m_strOption =""; + string m_strNormalText =""; + bool bScanDone =false; + int ndx =0; + int ldx =0; + char ch ; + try + { + for ( int i=0; i < m_strLineToProcess.Length ; i++) + { + Char ss = Convert.ToChar(m_strLineToProcess[i]); + m_strTemp = m_strTemp + Convert.ToString(ss); + } + + while(bScanDone != true ) + { + int lensmk = m_strTemp.Length; + ndx = m_strTemp.IndexOf(Convert.ToString(IAC)); + if ( ndx > lensmk ) + ndx = m_strTemp.Length; + + if(ndx != -1) + { + m_DISPLAYTEXT+= m_strTemp.Substring(0,ndx); + ch = m_strTemp[ndx + 1]; + if ( ch == DO || ch == DONT || ch == WILL || ch == WONT ) + { + m_strOption = m_strTemp.Substring(ndx, 3); + string txt = m_strTemp.Substring(ndx + 3); + m_DISPLAYTEXT+= m_strTemp.Substring(0,ndx); + m_ListOptions.Add(m_strOption); + m_strTemp = txt ; + } + else + if ( ch == IAC) + { + m_DISPLAYTEXT= m_strTemp.Substring(0,ndx); + m_strTemp = m_strTemp.Substring(ndx + 1); + } + else + if ( ch == SB ) + { + m_DISPLAYTEXT= m_strTemp.Substring(0,ndx); + ldx = m_strTemp.IndexOf(Convert.ToString(SE)); + m_strOption = m_strTemp.Substring(ndx, ldx); + m_ListOptions.Add(m_strOption); + m_strTemp = m_strTemp.Substring(ldx); + } + } + else + { + m_DISPLAYTEXT = m_DISPLAYTEXT + m_strTemp; + bScanDone = true ; + } + } + m_strNormalText = m_DISPLAYTEXT; + } + catch(Exception eP) + { + MessageBox.Show(eP.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop ); + Application.Exit(); + } + return m_strNormalText ; + } + + void DispatchMessage(string strText) + { + try + { + Byte[] smk = new Byte[strText.Length]; + for ( int i=0; i < strText.Length ; i++) + { + Byte ss = Convert.ToByte(strText[i]); + smk[i] = ss ; + } + + IAsyncResult ar2 = s.BeginSend(smk , 0 , smk.Length , SocketFlags.None , callbackProc , s ); + s.EndSend(ar2); + } + catch(Exception ers) + { + MessageBox.Show("ERROR IN RESPOND OPTIONS"); + } + } + + void RespondToOptions() + { + try + { + string strOption; + for ( int i=0; i < m_ListOptions.Count; i++) + { + strOption = (string)m_ListOptions[i]; + ArrangeReply(strOption); + } + DispatchMessage(m_strResp); + m_strResp =""; + m_ListOptions.Clear(); + } + catch(Exception ers) + { + MessageBox.Show("ERROR IN RESPOND OPTIONS"); + } + } + void ArrangeReply(string strOption) + { + try + { + + Char Verb; + Char Option; + Char Modifier; + Char ch; + bool bDefined = false; + + if(strOption.Length < 3) return; + + Verb = strOption[1]; + Option = strOption[2]; + + if ( Option == 1 || Option == 3 ) + { + // case 1: // Echo + // case 3: // Suppress Go-Ahead + bDefined = true; + // break; + } + + m_strResp += IAC; + + if(bDefined == true ) + { + if ( Verb == DO ) + { + // case DO: + ch = WILL; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == DONT ) + { + ch = WONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == WILL ) + { + ch = DO; + m_strResp += ch; + m_strResp += Option; + //break; + } + if ( Verb == WONT) + { + ch = DONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == SB) + { + Modifier = strOption[3]; + if(Modifier == SEND) + { + ch = SB; + m_strResp += ch; + m_strResp += Option; + m_strResp += IS; + m_strResp += IAC; + m_strResp += SE; + } + // break; + } + } + else + { + // switch(Verb) + // { + if ( Verb == DO ) + { + ch = WONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == DONT) + { + ch = WONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == WILL) + { + ch = DONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + if ( Verb == WONT) + { + ch = DONT; + m_strResp += ch; + m_strResp += Option; + // break; + } + } + } + catch(Exception eeeee ) + { + MessageBox.Show(eeeee.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop ); + Application.Exit(); + } + + } + + private void textBox1_KeyPress_1(object sender, System.Windows.Forms.KeyPressEventArgs e) + { + if ( e.KeyChar == 13 ) + { + DispatchMessage("\r\n"); + } + else + if ( e.KeyChar == 8 ) + { + try + { +// string mtmp = textBox1.Text.Substring(0,textBox1.Text.Length-1); +// textBox1.Text = "" ; + } + catch(Exception ebs) + { + MessageBox.Show("ERROR IN BACKSPACE"); + } + } + else + { + string str = e.KeyChar.ToString(); + DispatchMessage(str); + } + } + + + } +} |