-
Notifications
You must be signed in to change notification settings - Fork 5
User defined script parameters #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
User defined script parameters #11
Conversation
…sary using from CustomArgument.cs file.
…enuItem window with controls for adding user-defined arguments.
…Fixing data binding in AddOrEditUserDefinedArgument dialog.
- Renaming everything (types, variables) contains "argument", "arg" to "parameter", "param". - Moving extensions under own folder/namespace. - Fix for AddMenuItem dialog: not saved user-defined parameters with the command.
AddMenuItem: passing parameters coming from (execution) context as part of parameter names in use. AddUserDefinedParameter: refactored validation. Modified exception message in Parameter getter. OptionsDialogPage: adding validation for MenuItems when user clicks OK on Options page. Changes will be discarded if user clicks on Cancel or closes the Options page. SSMSObjectExplorerMenu: replacing user-defined parameters in T-SQL script of the MenuItem/command. Utils: fix context parameter names. Extensions: added ReplaceRange extension method. Removed unnecessary empty lines. UIExtensions: added ToUserDefinedArgument extension method. MenuItem: added validation. UserDefinedArgument added. ArgumentControl: new control for entering value for a user-defined parameter. EnterUserDefinedArgument: new dialog for entering parameter values before executing the T-SQL script of the MenuItem/command.
- AddMenuItem: making user-defined parameter listview larger & resizeable. Increasing window & control sizes. - AddUserDefinedParameter: displaying window in center of parent, modify sytle. - EnterUserDefinedArgument: displaying window in center of parent, modify sytle. Auto-sized flowLayoutPanel.
… saving value list.
…ow issues: - "Server/Database/Table/Column" could not be selected on the AddMenuItem dialog as the new command's context. - In the Options grid, Context property of the command/menu item could be edited via a text box. This was error prone - in case of a typo, the command disappeared from the Object Explorer context menu. Now it can be selected from a dropdown.
…up. Allowin editing parameters on the AddMenuItem dialog.
- displaying the full path in the Context field of the exported XML - accepting string containing the full path to parse the appropriate MenuItemContext value.
Minor UI changes. Fix the issue when validation threw an exception in case the user did not enter anything for parameter name (UserDefinedParameter.cs)
| namespace SSMSObjectExplorerMenu.enums | ||
| { | ||
| [Flags] | ||
| public enum MenuItemContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a feature breaking change. The original list of menu item contexts displayed in the drop down in the Add Menu Item window was non-exhaustive. The current context was added at runtime to the dropdown and set at the current value. This change limits where, at what context, menu items can be added.
ArgumentControl.cs
Outdated
| _valueControl = textBox; | ||
| } | ||
|
|
||
| private void Init_Int() => _valueControl = new NumericUpDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug. Does not allow the user to insert a negative value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I'll fix this one.
|
|
||
| namespace SSMSObjectExplorerMenu.enums | ||
| { | ||
| public enum UserDefinedParameterType : byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature request. Could we please add DateTime as another option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can add it. It does not seem much extra work.
|
|
||
| namespace SSMSObjectExplorerMenu | ||
| { | ||
| public partial class EnterUserDefinedArguments : Form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug. Form will need to be resizable to handle case where many parameters are defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current way this form works is:
- In the dialog, there is a container (a FlowLayoutPanel) which holds the inputs for the arguments
- This input has a default height of 50px. It grows automatically, until it reaches height of 200px. If there are more elements, this container will have a vertical scrollbar - so, you can scroll down for the rest of the elements.
What kind of behavior would you suggest instead the above one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply make the form resizable and achor the flow panel to resize with form.
| namespace SSMSObjectExplorerMenu | ||
| { | ||
| public partial class EnterUserDefinedArguments : Form | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug. Parameter controls are too wide, forcing the horizontal scroll bar to always be displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting... I see no horizontal scrollbar. However, when I provide a long parameter name, the end of it is just not visible. To be honest, that's why I introduced the NAME_MAX_LENGTH constant in UserDefinedParameter.cs file. Maybe I should reduce the maximum length limit further.
Anyway, I will look into this and try to reproduce this horizontal scrollbar issue you mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| namespace SSMSObjectExplorerMenu.objects | ||
| { | ||
| [TypeConverter(typeof(ExpandableObjectConverter))] | ||
| public class UserDefinedParameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature request. Option to set a default/initial value when configuring menu item parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This crossed my mind also during development... would you do it mandatory to specify a default value each parameter, or it would be just an option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either is fine. Making it mandatory might make the coding easier.
…dow. The flow panel and window now resize in sync.
…ed unused padding.

Extending the current add-on with the feature of adding custom parameters (tags) to the menu items. Read the updated README.md for the high level description of the feature. I have added notes below which (hopefully) will help during the review.
AddMenuItem.cs (dialog)
OptionsDialogPage.cs
SSMSObjectExplorerMenu.cs
MenuItem.cs
AddUserDefinedParameter.cs (dialog)
EnterUserDefinedArguments.cs (dialog)
OptionsDialogPage.cs
SSMSObjectExplorerMenu.cs
MenuItem.cs
AddUserDefinedParameter.cs (dialog)
EnterUserDefinedArguments.cs (dialog)
ArgumentControl.cs (control)
EnumConverter.cs, MenuItemContextConverter.cs, UserDefinedArgumentTypeConverter.cs
ArgumentControl.cs (control)
EnumConverter.cs, MenuItemContextConverter.cs, UserDefinedArgumentTypeConverter.cs