Skip to content

Commit 6202be0

Browse files
committed
Initial commit
1 parent f0139c9 commit 6202be0

File tree

13 files changed

+2418
-0
lines changed

13 files changed

+2418
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PlsqlDeveloperUtPlsqlPlugin/.vs
2+
PlsqlDeveloperUtPlsqlPlugin/packages
3+
PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/bin
4+
PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/obj
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30804.86
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlsqlDeveloperUtPlsqlPlugin", "PlsqlDeveloperUtPlsqlPlugin\PlsqlDeveloperUtPlsqlPlugin.csproj", "{0241FA41-E396-491A-B4EC-772B694EC689}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{0241FA41-E396-491A-B4EC-772B694EC689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{0241FA41-E396-491A-B4EC-772B694EC689}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{0241FA41-E396-491A-B4EC-772B694EC689}.Debug|x64.ActiveCfg = Debug|x64
19+
{0241FA41-E396-491A-B4EC-772B694EC689}.Debug|x64.Build.0 = Debug|x64
20+
{0241FA41-E396-491A-B4EC-772B694EC689}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{0241FA41-E396-491A-B4EC-772B694EC689}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{0241FA41-E396-491A-B4EC-772B694EC689}.Release|x64.ActiveCfg = Release|x64
23+
{0241FA41-E396-491A-B4EC-772B694EC689}.Release|x64.Build.0 = Release|x64
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {AAEE5B87-8FAA-45A7-A122-60FBF4DA5170}
30+
EndGlobalSection
31+
EndGlobal
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
using System;
2+
using RGiesecke.DllExport;
3+
using System.Runtime.InteropServices;
4+
using System.Windows.Forms;
5+
using System.Drawing;
6+
using System.Reflection;
7+
using System.IO;
8+
9+
namespace PlsqlDeveloperUtPlsqlPlugin
10+
{
11+
//*FUNC: 11*/ BOOL (*IDE_Connected)();
12+
internal delegate bool IdeConnected();
13+
//*FUNC: 12*/ void (*IDE_GetConnectionInfo)(char **Username, char **Password, char **Database);
14+
internal delegate void IdeGetConnectionInfo(out IntPtr username, out IntPtr password, out IntPtr database);
15+
16+
//*FUNC: 40*/ int (*SQL_Execute)(char *SQL);
17+
internal delegate int SqlExecute(string sql);
18+
//*FUNC: 42*/ BOOL (*SQL_Eof)();
19+
internal delegate bool SqlEof();
20+
//*FUNC: 43*/ int (*SQL_Next)();
21+
internal delegate int SqlNext();
22+
//*FUNC: 44*/ char *(*SQL_Field)(int Field);
23+
internal delegate IntPtr SqlField(int field);
24+
//*FUNC: 48*/ char *(*SQL_ErrorMessage)();
25+
internal delegate IntPtr SqlErrorMessage();
26+
27+
//*FUNC: 69*/ void *(*IDE_CreatePopupItem)(int ID, int Index, char *Name, char *ObjectType);
28+
internal delegate void IdeCreatePopupItem(int id, int index, string name, string objectType);
29+
//*FUNC: 74*/ int (*IDE_GetPopupObject)(char **ObjectType, char **ObjectOwner, char **ObjectName, char **SubObject);
30+
internal delegate int IdeGetPopupObject(out IntPtr objectType, out IntPtr objectOwner, out IntPtr objectName, out IntPtr subObject);
31+
//*FUNC: 150*/ void (*IDE_CreateToolButton)(int ID, int Index, char *Name, char *BitmapFile, int BitmapHandle);
32+
internal delegate void IdeCreateToolButton(int id, int index, string name, string bitmapFile, long bitmapHandle);
33+
34+
public class PlsqlDeveloperUtPlsqlPlugin
35+
{
36+
private const string PLUGIN_NAME = "utPLSQL Plugin";
37+
38+
private const int PLUGIN_MENU_INDEX_ALLTESTS = 3;
39+
private const int PLUGIN_POPUP_INDEX = 1;
40+
41+
private const string ABOUT_TEXT = "utPLSQL Plugin for PL/SQL Developer \r\nby Simon Martinelli, 72® Services LLC";
42+
43+
private static PlsqlDeveloperUtPlsqlPlugin plugin;
44+
45+
internal static IdeConnected connected;
46+
internal static IdeGetConnectionInfo getConnectionInfo;
47+
48+
internal static SqlExecute sqlExecute;
49+
internal static SqlEof sqlEof;
50+
internal static SqlNext sqlNext;
51+
internal static SqlField sqlField;
52+
internal static SqlErrorMessage sqlErrorMessage;
53+
54+
internal static IdeCreatePopupItem createPopupItem;
55+
internal static IdeGetPopupObject getPopupObject;
56+
internal static IdeCreateToolButton createToolButton;
57+
58+
internal static int pluginId;
59+
60+
private static TestResultWindow testResultWindow ;
61+
62+
private PlsqlDeveloperUtPlsqlPlugin()
63+
{
64+
testResultWindow = new TestResultWindow();
65+
}
66+
67+
#region DLL exported API
68+
[DllExport("IdentifyPlugIn", CallingConvention = CallingConvention.Cdecl)]
69+
public static string IdentifyPlugIn(int id)
70+
{
71+
if (plugin == null)
72+
{
73+
plugin = new PlsqlDeveloperUtPlsqlPlugin();
74+
pluginId = id;
75+
}
76+
return PLUGIN_NAME;
77+
}
78+
79+
[DllExport("RegisterCallback", CallingConvention = CallingConvention.Cdecl)]
80+
public static void RegisterCallback(int index, IntPtr function)
81+
{
82+
switch (index)
83+
{
84+
case 11:
85+
connected = (IdeConnected)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeConnected));
86+
break;
87+
case 12:
88+
getConnectionInfo = (IdeGetConnectionInfo)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeGetConnectionInfo));
89+
break;
90+
case 40:
91+
sqlExecute = (SqlExecute)Marshal.GetDelegateForFunctionPointer(function, typeof(SqlExecute));
92+
break;
93+
case 42:
94+
sqlEof = (SqlEof)Marshal.GetDelegateForFunctionPointer(function, typeof(SqlEof));
95+
break;
96+
case 43:
97+
sqlNext = (SqlNext)Marshal.GetDelegateForFunctionPointer(function, typeof(SqlNext));
98+
break;
99+
case 44:
100+
sqlField = (SqlField)Marshal.GetDelegateForFunctionPointer(function, typeof(SqlField));
101+
break;
102+
case 48:
103+
sqlErrorMessage = (SqlErrorMessage)Marshal.GetDelegateForFunctionPointer(function, typeof(SqlErrorMessage));
104+
break;
105+
case 69:
106+
createPopupItem = (IdeCreatePopupItem)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeCreatePopupItem));
107+
break;
108+
case 74:
109+
getPopupObject = (IdeGetPopupObject)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeGetPopupObject));
110+
break;
111+
case 150:
112+
createToolButton = (IdeCreateToolButton)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeCreateToolButton));
113+
break;
114+
}
115+
}
116+
117+
[DllExport("CreateMenuItem", CallingConvention = CallingConvention.Cdecl)]
118+
public static string CreateMenuItem(int index)
119+
{
120+
switch (index)
121+
{
122+
case 1:
123+
return "TAB=Tools";
124+
case 2:
125+
return "GROUP=utPLSQL";
126+
case PLUGIN_MENU_INDEX_ALLTESTS:
127+
return "LARGEITEM=Run all tests of current user";
128+
default:
129+
return "";
130+
}
131+
}
132+
133+
[DllExport("OnActivate", CallingConvention = CallingConvention.Cdecl)]
134+
public static void OnActivate()
135+
{
136+
try
137+
{
138+
// Two seperate streams are needed!
139+
var assembly = Assembly.GetExecutingAssembly();
140+
using (Stream stream = assembly.GetManifestResourceStream("PlsqlDeveloperUtPlsqlPlugin.utPLSQL.bmp"))
141+
{
142+
createToolButton(pluginId, PLUGIN_MENU_INDEX_ALLTESTS, "utPLSQL", "utPLSQL.bmp", new Bitmap(stream).GetHbitmap().ToInt64());
143+
}
144+
using (Stream stream = assembly.GetManifestResourceStream("PlsqlDeveloperUtPlsqlPlugin.utPLSQL.bmp"))
145+
{
146+
createToolButton(pluginId, PLUGIN_POPUP_INDEX, "utPLSQL", "utPLSQL.bmp", new Bitmap(stream).GetHbitmap().ToInt64());
147+
}
148+
}
149+
catch (Exception e)
150+
{
151+
MessageBox.Show(e.Message);
152+
}
153+
createPopupItem(pluginId, PLUGIN_POPUP_INDEX, "Run utPLSQL Test", "USER");
154+
createPopupItem(pluginId, PLUGIN_POPUP_INDEX, "Run utPLSQL Test", "PACKAGE");
155+
}
156+
157+
[DllExport("OnMenuClick", CallingConvention = CallingConvention.Cdecl)]
158+
public static void OnMenuClick(int index)
159+
{
160+
if (index == PLUGIN_MENU_INDEX_ALLTESTS)
161+
{
162+
if (PlsqlDeveloperUtPlsqlPlugin.connected())
163+
{
164+
IntPtr username;
165+
IntPtr password;
166+
IntPtr database;
167+
getConnectionInfo(out username, out password, out database);
168+
169+
testResultWindow.RunTests("_ALL", Marshal.PtrToStringAnsi(username), null, null);
170+
}
171+
}
172+
else if (index == PLUGIN_POPUP_INDEX)
173+
{
174+
if (PlsqlDeveloperUtPlsqlPlugin.connected())
175+
{
176+
IntPtr type;
177+
IntPtr owner;
178+
IntPtr name;
179+
IntPtr subType;
180+
getPopupObject(out type, out owner, out name, out subType);
181+
182+
testResultWindow.RunTests(Marshal.PtrToStringAnsi(type), Marshal.PtrToStringAnsi(owner), Marshal.PtrToStringAnsi(name), Marshal.PtrToStringAnsi(subType));
183+
}
184+
}
185+
}
186+
187+
[DllExport("About", CallingConvention = CallingConvention.Cdecl)]
188+
public static string About()
189+
{
190+
MessageBox.Show(ABOUT_TEXT);
191+
return "";
192+
}
193+
#endregion
194+
}
195+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{0241FA41-E396-491A-B4EC-772B694EC689}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PlsqlDeveloperUtPlsqlPlugin</RootNamespace>
11+
<AssemblyName>PlsqlDeveloperUtPlsqlPlugin</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
<TargetFrameworkProfile />
16+
<NuGetPackageImportStamp>
17+
</NuGetPackageImportStamp>
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
28+
<Prefer32Bit>false</Prefer32Bit>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
38+
<Prefer32Bit>false</Prefer32Bit>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
41+
<DebugSymbols>true</DebugSymbols>
42+
<OutputPath>bin\x64\Debug\</OutputPath>
43+
<DefineConstants>DEBUG;TRACE</DefineConstants>
44+
<DebugType>full</DebugType>
45+
<PlatformTarget>x64</PlatformTarget>
46+
<LangVersion>7.3</LangVersion>
47+
<ErrorReport>prompt</ErrorReport>
48+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
49+
<Prefer32Bit>false</Prefer32Bit>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
52+
<OutputPath>bin\x64\Release\</OutputPath>
53+
<DefineConstants>TRACE</DefineConstants>
54+
<Optimize>true</Optimize>
55+
<DebugType>pdbonly</DebugType>
56+
<PlatformTarget>x64</PlatformTarget>
57+
<LangVersion>7.3</LangVersion>
58+
<ErrorReport>prompt</ErrorReport>
59+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
60+
<Prefer32Bit>false</Prefer32Bit>
61+
</PropertyGroup>
62+
<ItemGroup>
63+
<Reference Include="RGiesecke.DllExport.Metadata, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8f52d83c1a22df51, processorArchitecture=MSIL">
64+
<HintPath>..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll</HintPath>
65+
<Private>False</Private>
66+
</Reference>
67+
<Reference Include="System" />
68+
<Reference Include="System.Core" />
69+
<Reference Include="System.Drawing" />
70+
<Reference Include="System.Windows.Forms" />
71+
<Reference Include="System.Xml.Linq" />
72+
<Reference Include="System.Data.DataSetExtensions" />
73+
<Reference Include="Microsoft.CSharp" />
74+
<Reference Include="System.Data" />
75+
<Reference Include="System.Xml" />
76+
</ItemGroup>
77+
<ItemGroup>
78+
<Compile Include="TestRunner\JUnitTestSuites.cs" />
79+
<Compile Include="View\TestResultWindow.cs">
80+
<SubType>Form</SubType>
81+
</Compile>
82+
<Compile Include="View\TestResultWindow.Designer.cs">
83+
<DependentUpon>TestResultWindow.cs</DependentUpon>
84+
</Compile>
85+
<Compile Include="PlsqlDeveloperUtPlsqlPlugin.cs" />
86+
<Compile Include="Properties\AssemblyInfo.cs" />
87+
<Compile Include="TestRunner\TestRunner.cs" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<EmbeddedResource Include="View\TestResultWindow.resx">
91+
<DependentUpon>TestResultWindow.cs</DependentUpon>
92+
</EmbeddedResource>
93+
</ItemGroup>
94+
<ItemGroup>
95+
<EmbeddedResource Include="utPLSQL.bmp">
96+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
97+
</EmbeddedResource>
98+
</ItemGroup>
99+
<ItemGroup>
100+
<Content Include="utPLSQL.ico">
101+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
102+
</Content>
103+
</ItemGroup>
104+
<ItemGroup>
105+
<None Include="packages.config" />
106+
</ItemGroup>
107+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
108+
<Import Project="..\packages\UnmanagedExports.Repack.1.0.4\build\UnmanagedExports.Repack.targets" Condition="Exists('..\packages\UnmanagedExports.Repack.1.0.4\build\UnmanagedExports.Repack.targets')" />
109+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
110+
<PropertyGroup>
111+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
112+
</PropertyGroup>
113+
<Error Condition="!Exists('..\packages\UnmanagedExports.Repack.1.0.4\build\UnmanagedExports.Repack.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\UnmanagedExports.Repack.1.0.4\build\UnmanagedExports.Repack.targets'))" />
114+
</Target>
115+
<Import Project="../packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets" Condition="Exists('../packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets')" />
116+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PlsqlDeveloperUtPlsqlPlugin")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PlsqlDeveloperUtPlsqlPlugin")]
13+
[assembly: AssemblyCopyright("Copyright © 2020")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("0241fa41-e396-491a-b4ec-772b694ec689")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)