You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityConnectionStringBuilderItem.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Data.EntityClient;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityConnectionStringBuilderItem : IComparable<EntityConnectionStringBuilderItem>
|
||||
{
|
||||
// Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly.
|
||||
private readonly EntityConnectionStringBuilder _connectionStringBuilder;
|
||||
private readonly string _unknownConnectionString; // used when the string cannot be loaded into a connection string builder or is missing some required keywords
|
||||
|
||||
internal EntityConnectionStringBuilderItem(EntityConnectionStringBuilder connectionStringBuilder)
|
||||
{
|
||||
// empty connection string builder is allowed, but not null
|
||||
Debug.Assert(connectionStringBuilder != null, "null connectionStringBuilder");
|
||||
|
||||
_connectionStringBuilder = connectionStringBuilder;
|
||||
}
|
||||
|
||||
internal EntityConnectionStringBuilderItem(string unknownConnectionString)
|
||||
{
|
||||
// empty is not allowed -- use the constructor that takes a builder if the string is empty
|
||||
Debug.Assert(!String.IsNullOrEmpty(unknownConnectionString), "null or empty unknownConnectionString");
|
||||
_unknownConnectionString = unknownConnectionString;
|
||||
}
|
||||
|
||||
internal string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_connectionStringBuilder != null)
|
||||
{
|
||||
return _connectionStringBuilder.ConnectionString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _unknownConnectionString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal EntityConnectionStringBuilder EntityConnectionStringBuilder
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connectionStringBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.IsNullOrEmpty(this.ConnectionString);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNamedConnection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_connectionStringBuilder != null)
|
||||
{
|
||||
return !String.IsNullOrEmpty(_connectionStringBuilder.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the connection string is not recognized by a EntityConnectionStringBuilder, it can't be a valid named connection
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
// Display just the name for named connections, but the full connection string otherwise
|
||||
if (_connectionStringBuilder != null)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(_connectionStringBuilder.Name))
|
||||
{
|
||||
return _connectionStringBuilder.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _connectionStringBuilder.ConnectionString;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _unknownConnectionString;
|
||||
}
|
||||
}
|
||||
|
||||
int IComparable<EntityConnectionStringBuilderItem>.CompareTo(EntityConnectionStringBuilderItem other)
|
||||
{
|
||||
return (String.Compare(this.ToString(), other.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,318 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceConfigureObjectContext.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//
|
||||
// Manages the properties that can be set on the first page of the wizard
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
// delegate for event handler to process notifications when the DefaultContainerName is changed
|
||||
internal delegate void EntityDataSourceContainerChangedEventHandler(object sender, EntityDataSourceContainerNameItem newContainerName);
|
||||
|
||||
internal class EntityDataSourceConfigureObjectContext
|
||||
{
|
||||
#region Private readonly fields
|
||||
private readonly EntityDataSourceConfigureObjectContextPanel _panel;
|
||||
private readonly EntityDataSourceDesignerHelper _helper;
|
||||
#endregion
|
||||
|
||||
#region Private writeable fields
|
||||
private EntityDataSourceContainerChangedEventHandler _containerNameChanged; // used to notify the DataSelection panel that a change has been made
|
||||
#endregion
|
||||
|
||||
#region Private fields for temporary storage of property values
|
||||
private EntityConnectionStringBuilderItem _selectedConnectionStringBuilder;
|
||||
private bool _connectionStringHasValue;
|
||||
private List<EntityConnectionStringBuilderItem> _namedConnections;
|
||||
private List<EntityDataSourceContainerNameItem> _containerNames;
|
||||
private EntityDataSourceContainerNameItem _selectedContainerName;
|
||||
private readonly EntityDataSourceState _entityDataSourceState;
|
||||
private readonly EntityDataSourceWizardForm _wizardForm;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
internal EntityDataSourceConfigureObjectContext(EntityDataSourceConfigureObjectContextPanel panel, EntityDataSourceWizardForm wizardForm, EntityDataSourceDesignerHelper helper, EntityDataSourceState entityDataSourceState)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
_panel = panel;
|
||||
_helper = helper;
|
||||
|
||||
// Explicitly load metadata here to ensure that we get the latest changes in the project
|
||||
_helper.ReloadResources();
|
||||
|
||||
_panel.Register(this);
|
||||
|
||||
_wizardForm = wizardForm;
|
||||
_entityDataSourceState = entityDataSourceState;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
internal event EntityDataSourceContainerChangedEventHandler ContainerNameChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
_containerNameChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_containerNameChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
// Fires the event to notify that a container has been chosen from the list
|
||||
private void OnContainerNameChanged(EntityDataSourceContainerNameItem selectedContainerName)
|
||||
{
|
||||
if (_containerNameChanged != null)
|
||||
{
|
||||
_containerNameChanged(this, selectedContainerName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods to manage temporary state and wizard contents
|
||||
// Save current wizard settings back to the EntityDataSourceState
|
||||
internal void SaveState()
|
||||
{
|
||||
SaveConnectionString();
|
||||
SaveContainerName();
|
||||
}
|
||||
|
||||
// Load the initial state of the wizard
|
||||
internal void LoadState()
|
||||
{
|
||||
LoadConnectionStrings();
|
||||
LoadContainerNames(_entityDataSourceState.DefaultContainerName, true /*initialLoad*/);
|
||||
}
|
||||
|
||||
#region DefaultContainerName
|
||||
/// <summary>
|
||||
/// Populates the DefaultContainerName ComboBox with all of the EntityContainers in the loaded metadata
|
||||
/// If the specified DefaultContainerName property on the data source control is not empty and 'initialLoad' is true,
|
||||
/// it is added to the list and selected in the control
|
||||
/// </summary>
|
||||
/// <param name="containerName">The container name to find</param>
|
||||
/// <param name="initialLoad">if true, this is the initial load so the container name is added to the list if it is not found.</param>
|
||||
private void LoadContainerNames(string containerName, bool initialLoad)
|
||||
{
|
||||
// Get a list of EntityContainers from the metadata in the connection string
|
||||
_containerNames = _helper.GetContainerNames(false /*sortResults*/);
|
||||
|
||||
// Try to find the specified container in list
|
||||
_selectedContainerName = FindContainerName(containerName, initialLoad /*addIfNotFound*/);
|
||||
|
||||
// Sort the list now, after we may have added a new entry above
|
||||
_containerNames.Sort();
|
||||
|
||||
// Update the controls
|
||||
_panel.SetContainerNames(_containerNames);
|
||||
_panel.SetSelectedContainerName(_selectedContainerName, initialLoad /*initialLoad*/);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the current container in the current list of containers
|
||||
/// </summary>
|
||||
/// <param name="containerName">The container name to find</param>
|
||||
/// <param name="addIfNotFound">if true, adds the container name to the list if it is not found.</param>
|
||||
/// <returns></returns>
|
||||
private EntityDataSourceContainerNameItem FindContainerName(string containerName, bool addIfNotFound)
|
||||
{
|
||||
Debug.Assert(_containerNames != null, "_containerNames have already been initialized and should not be null");
|
||||
|
||||
if (!String.IsNullOrEmpty(containerName))
|
||||
{
|
||||
EntityDataSourceContainerNameItem containerToSelect = null;
|
||||
foreach (EntityDataSourceContainerNameItem containerNameItem in _containerNames)
|
||||
{
|
||||
// Ignore case here when searching the list for a matching item, but set the temporary state property to the
|
||||
// correctly-cased version from metadata so that if the user clicks Finish, the correct one will be saved. This
|
||||
// allows some flexibility the designer without preserving an incorrectly-cased value that could cause errors at runtime.
|
||||
if (String.Equals(containerName, containerNameItem.EntityContainerName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
containerToSelect = containerNameItem;
|
||||
}
|
||||
}
|
||||
|
||||
// didn't find a matching container, so just create a placeholder for one using the specified name and add it to the list
|
||||
if (containerToSelect == null && addIfNotFound)
|
||||
{
|
||||
containerToSelect = new EntityDataSourceContainerNameItem(containerName);
|
||||
_containerNames.Add(containerToSelect);
|
||||
}
|
||||
|
||||
Debug.Assert(addIfNotFound == false || containerToSelect != null, "expected a non-null EntityDataSourceContainerNameItem");
|
||||
return containerToSelect;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set the container name in temporary storage, update the connection string, and fire the event so the EntitySet will know there has been a change
|
||||
internal void SelectContainerName(EntityDataSourceContainerNameItem selectedContainer)
|
||||
{
|
||||
_selectedContainerName = selectedContainer;
|
||||
|
||||
UpdateWizardState();
|
||||
OnContainerNameChanged(_selectedContainerName);
|
||||
}
|
||||
|
||||
private void SaveContainerName()
|
||||
{
|
||||
Debug.Assert(_selectedContainerName != null, "wizard data should not be saved if container name is empty");
|
||||
_entityDataSourceState.DefaultContainerName = _selectedContainerName.EntityContainerName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ConnectionString
|
||||
// Populates the NamedConnection ComboBox with all of the EntityClient connections from the web.config.
|
||||
// If the specified connectionString is a named connection (if it contains "name=ConnectionName"), it is added to the list and selected.
|
||||
// If the specified connectionString is not a named connection, the plain connection string option is selected and populated with the specified value.
|
||||
private void LoadConnectionStrings()
|
||||
{
|
||||
// Get a list of all named EntityClient connections in the web.config
|
||||
_namedConnections = _helper.GetNamedEntityClientConnections(false /*sortResults*/);
|
||||
|
||||
EntityConnectionStringBuilderItem connStrBuilderItem = _helper.GetEntityConnectionStringBuilderItem(_entityDataSourceState.ConnectionString);
|
||||
Debug.Assert(connStrBuilderItem != null, "expected GetEntityConnectionStringBuilder to always return non-null");
|
||||
|
||||
if (connStrBuilderItem.IsNamedConnection)
|
||||
{
|
||||
// Try to find the specified connection in the list or add it
|
||||
connStrBuilderItem = FindCurrentNamedConnection(connStrBuilderItem);
|
||||
Debug.Assert(connStrBuilderItem != null, "expected a non-null connStrBuilderItem for the named connection because it should have added it if it didn't exist");
|
||||
}
|
||||
|
||||
// Sort results now, after we may have added a new item above
|
||||
_namedConnections.Sort();
|
||||
|
||||
SelectConnectionStringBuilder(connStrBuilderItem, false /*resetContainer*/);
|
||||
|
||||
// Update the controls
|
||||
_panel.SetNamedConnections(_namedConnections);
|
||||
_panel.SetConnectionString(_selectedConnectionStringBuilder);
|
||||
}
|
||||
|
||||
// Find the current named connection in the list of connections
|
||||
// The returned item may refer to the same connection as the specified item, but it will be the actual reference from the list
|
||||
private EntityConnectionStringBuilderItem FindCurrentNamedConnection(EntityConnectionStringBuilderItem newBuilderItem)
|
||||
{
|
||||
Debug.Assert(_namedConnections != null, "_namedConnections should have already been initialized and should not be null");
|
||||
Debug.Assert(newBuilderItem != null && newBuilderItem.IsNamedConnection, "expected non-null newBuilderItem");
|
||||
|
||||
foreach (EntityConnectionStringBuilderItem namedConnectionItem in _namedConnections)
|
||||
{
|
||||
if (((IComparable<EntityConnectionStringBuilderItem>)newBuilderItem).CompareTo(namedConnectionItem) == 0)
|
||||
{
|
||||
// returning the one that was actually in the list, so we can select it in the control
|
||||
return namedConnectionItem;
|
||||
}
|
||||
}
|
||||
|
||||
// didn't find it in the list, so add it
|
||||
_namedConnections.Add(newBuilderItem);
|
||||
return newBuilderItem;
|
||||
}
|
||||
|
||||
internal EntityConnectionStringBuilderItem GetEntityConnectionStringBuilderItem(string connectionString)
|
||||
{
|
||||
return _helper.GetEntityConnectionStringBuilderItem(connectionString);
|
||||
}
|
||||
|
||||
// Set the connection string in temporary storage
|
||||
// Returns true if the metadata was successfully loaded for the specified connections
|
||||
internal bool SelectConnectionStringBuilder(EntityConnectionStringBuilderItem selectedConnection, bool resetContainer)
|
||||
{
|
||||
_selectedConnectionStringBuilder = selectedConnection;
|
||||
|
||||
bool metadataLoaded = false;
|
||||
if (selectedConnection != null)
|
||||
{
|
||||
if (selectedConnection.EntityConnectionStringBuilder != null)
|
||||
{
|
||||
metadataLoaded = _helper.LoadMetadata(selectedConnection.EntityConnectionStringBuilder);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since we don't have a valid connection string builder, we don't have enough information to load metadata.
|
||||
// Clear any existing metadata so we don't see an old item collection on any subsequent calls that access it.
|
||||
// Don't need to display an error here because that was handled by the caller who created the builder item
|
||||
_helper.ClearMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the list of containers if requested and set the ComboBox to have no selection.
|
||||
// In some cases the containers do not need to be reset because the caller wants to delay that until a later event or wants to preserve a specific value
|
||||
if (resetContainer)
|
||||
{
|
||||
string defaultContainerName = _selectedConnectionStringBuilder.EntityConnectionStringBuilder == null ? null : _selectedConnectionStringBuilder.EntityConnectionStringBuilder.Name;
|
||||
LoadContainerNames(defaultContainerName, false /*initialLoad*/);
|
||||
}
|
||||
|
||||
// Update the controls
|
||||
UpdateWizardState();
|
||||
|
||||
return metadataLoaded;
|
||||
}
|
||||
|
||||
// Set a flag indicating that the connection string textbox or named connection dropdown has a value
|
||||
// This value has not be verified at this point, or may not even be complete, so we don't want to validate it yet and turn it into a builder
|
||||
internal void SelectConnectionStringHasValue(bool connectionStringHasValue)
|
||||
{
|
||||
_connectionStringHasValue = connectionStringHasValue;
|
||||
|
||||
// Update the controls
|
||||
UpdateWizardState();
|
||||
}
|
||||
|
||||
private void SaveConnectionString()
|
||||
{
|
||||
Debug.Assert(_selectedConnectionStringBuilder != null, "wizard data should not be saved if connection string is empty");
|
||||
_entityDataSourceState.ConnectionString = _selectedConnectionStringBuilder.ConnectionString;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Wizard button state management
|
||||
// Update the state of the wizard buttons
|
||||
internal void UpdateWizardState()
|
||||
{
|
||||
_wizardForm.SetCanNext(this.CanEnableNext);
|
||||
|
||||
// Finish button should never be enabled at this stage
|
||||
_wizardForm.SetCanFinish(false);
|
||||
}
|
||||
|
||||
// Next button can only be enabled when the following are true:
|
||||
// (1) DefaultContainerName has a value
|
||||
// (2) Either a named connection is selected or the connection string textbox has a value
|
||||
internal bool CanEnableNext
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedContainerName != null && _connectionStringHasValue;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,385 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceConfigureObjectContextPanel.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal partial class EntityDataSourceConfigureObjectContextPanel : WizardPanel
|
||||
{
|
||||
private EntityDataSourceConfigureObjectContext _configureObjectContext;
|
||||
private bool _ignoreEvents; // used when a control value is set by the wizard, tells the event handlers to do nothing
|
||||
private bool _connectionInEdit; // indicates that a change has been made to the connection and it has not yet been validated
|
||||
|
||||
#region Constructors
|
||||
internal EntityDataSourceConfigureObjectContextPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeUI();
|
||||
InitializeTabIndexes();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region General initialization
|
||||
internal void Register(EntityDataSourceConfigureObjectContext configureObjectContext)
|
||||
{
|
||||
_configureObjectContext = configureObjectContext;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Control Initialization
|
||||
private void InitializeSizes()
|
||||
{
|
||||
int top = 25;
|
||||
|
||||
_databaseConnectionGroupLabel.Location = new Point(10, top);
|
||||
_databaseConnectionGroupLabel.Size = new Size(500, 13);
|
||||
top = _databaseConnectionGroupLabel.Bottom;
|
||||
|
||||
_databaseConnectionGroupBox.Location = new Point(13, top);
|
||||
_databaseConnectionGroupBox.Size = new Size(503, 124);
|
||||
top = 0; // rest of controls in this group are positioned relative to the group box, so top resets
|
||||
|
||||
_namedConnectionRadioButton.Location = new Point(9, top + 20);
|
||||
_namedConnectionRadioButton.Size = new Size(116, 17);
|
||||
top = _namedConnectionRadioButton.Bottom;
|
||||
|
||||
_namedConnectionComboBox.Location = new Point(25, top + 6);
|
||||
_namedConnectionComboBox.Size = new Size(454, 21);
|
||||
top = _namedConnectionComboBox.Bottom;
|
||||
|
||||
_connectionStringRadioButton.Location = new Point(9, top + 6);
|
||||
_connectionStringRadioButton.Size = new Size(109, 17);
|
||||
top = _connectionStringRadioButton.Bottom;
|
||||
|
||||
_connectionStringTextBox.Location = new Point(25, top + 6);
|
||||
_connectionStringTextBox.Size = new Size(454, 20);
|
||||
top = _databaseConnectionGroupBox.Bottom;
|
||||
|
||||
_containerNameLabel.Location = new Point(10, top + 30);
|
||||
_containerNameLabel.Size = new Size(117, 13);
|
||||
top = _containerNameLabel.Bottom;
|
||||
|
||||
_containerNameComboBox.Location = new Point(13, top + 3);
|
||||
_containerNameComboBox.Size = new Size(502, 21);
|
||||
// if any controls are added, top should be reset to _containerNameComboBox.Bottom before adding them here
|
||||
}
|
||||
|
||||
private void InitializeTabIndexes()
|
||||
{
|
||||
_databaseConnectionGroupLabel.TabStop = false;
|
||||
_databaseConnectionGroupBox.TabStop = false;
|
||||
_namedConnectionComboBox.TabStop = true;
|
||||
_connectionStringTextBox.TabStop = true;
|
||||
_containerNameLabel.TabStop = false;
|
||||
_containerNameComboBox.TabStop = true;
|
||||
|
||||
int tabIndex = 0;
|
||||
_databaseConnectionGroupLabel.TabIndex = tabIndex += 10;
|
||||
_databaseConnectionGroupBox.TabIndex = tabIndex += 10;
|
||||
_namedConnectionRadioButton.TabIndex = tabIndex += 10;
|
||||
_namedConnectionComboBox.TabIndex = tabIndex += 10;
|
||||
_connectionStringRadioButton.TabIndex = tabIndex += 10;
|
||||
_connectionStringTextBox.TabIndex = tabIndex += 10;
|
||||
_containerNameLabel.TabIndex = tabIndex += 10;
|
||||
_containerNameComboBox.TabIndex = tabIndex += 10;
|
||||
}
|
||||
|
||||
private void InitializeUI()
|
||||
{
|
||||
this._databaseConnectionGroupLabel.Text = Strings.Wizard_ObjectContextPanel_ConnectionStringGroupDescription;
|
||||
this._connectionStringRadioButton.Text = Strings.Wizard_ObjectContextPanel_ConnectionStringRadioButton;
|
||||
this._connectionStringRadioButton.AccessibleName = Strings.Wizard_ObjectContextPanel_ConnectionStringRadioButtonAccessibleName;
|
||||
this._connectionStringTextBox.AccessibleName = Strings.Wizard_ObjectContextPanel_ConnectionStringRadioButtonAccessibleName;
|
||||
this._namedConnectionRadioButton.Text = Strings.Wizard_ObjectContextPanel_NamedConnectionRadioButton;
|
||||
this._namedConnectionRadioButton.AccessibleName = Strings.Wizard_ObjectContextPanel_NamedConnectionRadioButtonAccessibleName;
|
||||
this._namedConnectionComboBox.AccessibleName = Strings.Wizard_ObjectContextPanel_NamedConnectionRadioButtonAccessibleName;
|
||||
this._containerNameLabel.Text = Strings.Wizard_ObjectContextPanel_DefaultContainerName;
|
||||
this._containerNameComboBox.AccessibleName = Strings.Wizard_ObjectContextPanel_DefaultContainerNameAccessibleName;
|
||||
this.Caption = Strings.Wizard_ObjectContextPanel_Caption;
|
||||
this.AccessibleName = Strings.Wizard_ObjectContextPanel_Caption;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Control Event Handlers
|
||||
private void OnConnectionStringRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
if (_connectionStringRadioButton.Checked)
|
||||
{
|
||||
// Update the state of the controls that are associated with the radio buttons
|
||||
_namedConnectionComboBox.Enabled = false;
|
||||
_connectionStringTextBox.Enabled = true;
|
||||
|
||||
EnterConnectionEditMode();
|
||||
|
||||
// Update the flag to track if we have text in the box
|
||||
_configureObjectContext.SelectConnectionStringHasValue(!String.IsNullOrEmpty(_connectionStringTextBox.Text));
|
||||
|
||||
// Move the focus to the associated TextBox
|
||||
_connectionStringTextBox.Select();
|
||||
_connectionStringTextBox.Select(0, _connectionStringTextBox.TextLength);
|
||||
}
|
||||
}
|
||||
// else it's being unchecked, so that means another radio button is being checked and that handler will take care of updating the state
|
||||
}
|
||||
|
||||
private void OnConnectionStringTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
// If we aren't already in edit mode, move to it that we will know we need to reload metadata if it's needed later
|
||||
if (!_connectionInEdit)
|
||||
{
|
||||
EnterConnectionEditMode();
|
||||
}
|
||||
|
||||
// Update the state of the flag that tracks if there is anything in this TextBox.
|
||||
// This will cause the Next button to be disabled if all of the text is removed from the box, otherwise it is enabled
|
||||
_configureObjectContext.SelectConnectionStringHasValue(!String.IsNullOrEmpty(_connectionStringTextBox.Text));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNamedConnectionRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
if (_namedConnectionRadioButton.Checked)
|
||||
{
|
||||
// update the controls that are associated with the radio buttons
|
||||
_namedConnectionComboBox.Enabled = true;
|
||||
_connectionStringTextBox.Enabled = false;
|
||||
|
||||
EnterConnectionEditMode();
|
||||
|
||||
// Update flag to indicate if there is a value selected in this box
|
||||
_configureObjectContext.SelectConnectionStringHasValue(_namedConnectionComboBox.SelectedIndex != -1);
|
||||
|
||||
// Move the focus to the associated ComboBox
|
||||
_namedConnectionComboBox.Select();
|
||||
|
||||
// If there is a selected NamedConnection, validate the connection string right away
|
||||
// so that we can potentially select the default container name if there is one
|
||||
if (_namedConnectionComboBox.SelectedIndex != -1)
|
||||
{
|
||||
VerifyConnectionString();
|
||||
}
|
||||
}
|
||||
// else it's being unchecked, so that means another radio button is being checked and that handler will take care of updating the state
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNamedConnectionComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
EnterConnectionEditMode();
|
||||
|
||||
// Update flag to indicate if there is a value selected in this box
|
||||
_configureObjectContext.SelectConnectionStringHasValue(_namedConnectionComboBox.SelectedIndex != -1);
|
||||
|
||||
// If there is a selected NamedConnection, validate the connection string right away
|
||||
// so that we can potentially select the default container name if there is one
|
||||
if (_namedConnectionComboBox.SelectedIndex != -1)
|
||||
{
|
||||
VerifyConnectionString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnContainerNameComboBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
VerifyConnectionString();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnContainerNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_configureObjectContext.SelectContainerName(_containerNameComboBox.SelectedItem as EntityDataSourceContainerNameItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Move to edit mode so that we will know we need to reload metadata if it's needed later
|
||||
private void EnterConnectionEditMode()
|
||||
{
|
||||
_connectionInEdit = true;
|
||||
_containerNameComboBox.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
private void LeaveConnectionEditMode()
|
||||
{
|
||||
_connectionInEdit = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the selected connection string and load the metadata for it if it is successfully verified
|
||||
/// </summary>
|
||||
/// <returns>True if the metadata was successfully loaded from the connection string</returns>
|
||||
private bool VerifyConnectionString()
|
||||
{
|
||||
try
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
if (_connectionInEdit)
|
||||
{
|
||||
bool isNamedConnection = _namedConnectionRadioButton.Checked;
|
||||
Debug.Assert(!isNamedConnection ? _connectionStringRadioButton.Checked : true, "only expecting either named connection or connection string radio button options");
|
||||
|
||||
EntityConnectionStringBuilderItem selectedConnection = null;
|
||||
if (isNamedConnection)
|
||||
{
|
||||
if (_namedConnectionComboBox.SelectedIndex != -1)
|
||||
{
|
||||
selectedConnection = _namedConnectionComboBox.SelectedItem as EntityConnectionStringBuilderItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make a builder item out of the specified connection string. This will do some basic verification on the string.
|
||||
selectedConnection = _configureObjectContext.GetEntityConnectionStringBuilderItem(_connectionStringTextBox.Text);
|
||||
}
|
||||
|
||||
if (selectedConnection != null)
|
||||
{
|
||||
bool metadataLoaded = _configureObjectContext.SelectConnectionStringBuilder(selectedConnection, true /*resetContainer*/);
|
||||
|
||||
// If verification failed, try to move the focus back to the appropriate control.
|
||||
if (!metadataLoaded)
|
||||
{
|
||||
if (_namedConnectionRadioButton.Checked)
|
||||
{
|
||||
_namedConnectionComboBox.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
_connectionStringTextBox.Select();
|
||||
_connectionStringTextBox.Select(0, _connectionStringTextBox.TextLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Leave connection edit mode regardless of whether the metadata was loaded or not, because there is no need to keep trying
|
||||
// to validated it over and over again unless the user makes a change that puts it back into edit mode again
|
||||
LeaveConnectionEditMode();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Wizard state management
|
||||
public override bool OnNext()
|
||||
{
|
||||
Debug.Assert(_configureObjectContext.CanEnableNext, "OnNext called when CanEnableNext is false");
|
||||
|
||||
return VerifyConnectionString();
|
||||
}
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
{
|
||||
base.OnVisibleChanged(e);
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
_configureObjectContext.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods for setting control values
|
||||
// Expects that the specified builder item is a named connection already in the list, is a full connection string, or is empty
|
||||
// If empty, the default is to select the named connection option and don't select anything in the list
|
||||
internal void SetConnectionString(EntityConnectionStringBuilderItem connStrBuilderItem)
|
||||
{
|
||||
Debug.Assert(connStrBuilderItem != null, "expected non-null connStrBuilderItem");
|
||||
|
||||
_ignoreEvents = true;
|
||||
|
||||
// set the state of the ConnectionString radio buttons and associated controls
|
||||
bool isNamedConnection = connStrBuilderItem.IsEmpty || connStrBuilderItem.IsNamedConnection;
|
||||
|
||||
_namedConnectionRadioButton.Checked = isNamedConnection;
|
||||
_namedConnectionComboBox.Enabled = isNamedConnection;
|
||||
_connectionStringRadioButton.Checked = !isNamedConnection;
|
||||
_connectionStringTextBox.Enabled = !isNamedConnection;
|
||||
|
||||
// set the value of the control that was just enabled
|
||||
if (connStrBuilderItem.IsEmpty)
|
||||
{
|
||||
_namedConnectionComboBox.SelectedIndex = -1;
|
||||
_configureObjectContext.SelectConnectionStringHasValue(false /*connectionStringHasValue*/);
|
||||
}
|
||||
else if (connStrBuilderItem.IsNamedConnection)
|
||||
{
|
||||
_namedConnectionComboBox.SelectedItem = connStrBuilderItem;
|
||||
_configureObjectContext.SelectConnectionStringHasValue(true /*connectionStringHasValue*/);
|
||||
}
|
||||
else
|
||||
{
|
||||
_connectionStringTextBox.Text = connStrBuilderItem.ConnectionString;
|
||||
_configureObjectContext.SelectConnectionStringHasValue(!connStrBuilderItem.IsEmpty);
|
||||
}
|
||||
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
internal void SetContainerNames(List<EntityDataSourceContainerNameItem> containerNames)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_containerNameComboBox.Items.Clear();
|
||||
_containerNameComboBox.Items.AddRange(containerNames.ToArray());
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
internal void SetNamedConnections(List<EntityConnectionStringBuilderItem> namedConnections)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_namedConnectionComboBox.Items.AddRange(namedConnections.ToArray());
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expects that selectedContainer is already in the ComboBox list, or should be null
|
||||
/// </summary>
|
||||
/// <param name="selectedContainer"></param>
|
||||
/// <param name="initialLoad">If this is the initial load, we want to suppress events so that the change does
|
||||
/// not cause additional work in panels that listen to the container name changed event</param>
|
||||
internal void SetSelectedContainerName(EntityDataSourceContainerNameItem selectedContainer, bool initialLoad)
|
||||
{
|
||||
if (initialLoad)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
}
|
||||
if (selectedContainer == null)
|
||||
{
|
||||
_containerNameComboBox.SelectedIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_containerNameComboBox.SelectedItem = selectedContainer;
|
||||
}
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceConfigureObjectContextPanel.designer.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Windows.Forms;
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
partial class EntityDataSourceConfigureObjectContextPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this._databaseConnectionGroupLabel = new System.Windows.Forms.Label();
|
||||
this._databaseConnectionGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this._namedConnectionRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this._namedConnectionComboBox = new System.Windows.Forms.ComboBox();
|
||||
this._connectionStringTextBox = new System.Windows.Forms.TextBox();
|
||||
this._connectionStringRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this._containerNameLabel = new System.Windows.Forms.Label();
|
||||
this._containerNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
this.InitializeSizes();
|
||||
|
||||
//
|
||||
// _databaseConnectionGroupLabel
|
||||
//
|
||||
this._databaseConnectionGroupLabel.AutoSize = true;
|
||||
this._databaseConnectionGroupLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._databaseConnectionGroupLabel.Name = "_databaseConnectionGroupLabel";
|
||||
//
|
||||
// _databaseConnectionGroupBox
|
||||
//
|
||||
this._databaseConnectionGroupBox.Controls.Add(this._namedConnectionRadioButton);
|
||||
this._databaseConnectionGroupBox.Controls.Add(this._namedConnectionComboBox);
|
||||
this._databaseConnectionGroupBox.Controls.Add(this._connectionStringRadioButton);
|
||||
this._databaseConnectionGroupBox.Controls.Add(this._connectionStringTextBox);
|
||||
this._databaseConnectionGroupBox.Name = "_databaseConnectionGroupBox";
|
||||
this._databaseConnectionGroupBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// _namedConnectionRadioButton
|
||||
//
|
||||
this._namedConnectionRadioButton.AutoSize = true;
|
||||
this._namedConnectionRadioButton.Checked = true;
|
||||
this._namedConnectionRadioButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._namedConnectionRadioButton.Name = "_namedConnectionRadioButton";
|
||||
this._namedConnectionRadioButton.UseVisualStyleBackColor = true;
|
||||
this._namedConnectionRadioButton.CheckedChanged += new System.EventHandler(this.OnNamedConnectionRadioButton_CheckedChanged);
|
||||
//
|
||||
// _namedConnectionComboBox
|
||||
//
|
||||
this._namedConnectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this._namedConnectionComboBox.FormattingEnabled = true;
|
||||
this._namedConnectionComboBox.Name = "_namedConnectionComboBox";
|
||||
this._namedConnectionComboBox.SelectedIndexChanged += new EventHandler(OnNamedConnectionComboBox_SelectedIndexChanged);
|
||||
this._namedConnectionComboBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// _connectionStringRadioButton
|
||||
//
|
||||
this._connectionStringRadioButton.AutoSize = true;
|
||||
this._connectionStringRadioButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._connectionStringRadioButton.Name = "_connectionStringRadioButton";
|
||||
this._connectionStringRadioButton.UseVisualStyleBackColor = true;
|
||||
this._connectionStringRadioButton.CheckedChanged += new System.EventHandler(this.OnConnectionStringRadioButton_CheckedChanged);
|
||||
//
|
||||
// _connectionStringTextBox
|
||||
//
|
||||
this._connectionStringTextBox.Enabled = false;
|
||||
this._connectionStringTextBox.Name = "_connectionStringTextBox";
|
||||
this._connectionStringTextBox.TextChanged += new EventHandler(this.OnConnectionStringTextBox_TextChanged);
|
||||
this._connectionStringTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// _containerNameLabel
|
||||
//
|
||||
this._containerNameLabel.AutoSize = true;
|
||||
this._containerNameLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._containerNameLabel.Name = "_containerNameLabel";
|
||||
//
|
||||
// _containerNameComboBox
|
||||
//
|
||||
this._containerNameComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this._containerNameComboBox.FormattingEnabled = true;
|
||||
this._containerNameComboBox.Name = "_containerNameComboBox";
|
||||
this._containerNameComboBox.Enter += new EventHandler(OnContainerNameComboBox_Enter);
|
||||
this._containerNameComboBox.SelectedIndexChanged += new System.EventHandler(this.OnContainerNameComboBox_SelectedIndexChanged);
|
||||
this._containerNameComboBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// EntityDataSourceConfigureObjectContextPanel
|
||||
//
|
||||
this.Controls.Add(this._databaseConnectionGroupLabel);
|
||||
this.Controls.Add(this._databaseConnectionGroupBox);
|
||||
this.Controls.Add(this._containerNameLabel);
|
||||
this.Controls.Add(this._containerNameComboBox);
|
||||
this.Name = "EntityDataSourceConfigureObjectContextPanel";
|
||||
this.Size = new System.Drawing.Size(528, 319);
|
||||
this.MinimumSize = this.Size;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
private System.Windows.Forms.Label _databaseConnectionGroupLabel;
|
||||
private System.Windows.Forms.GroupBox _databaseConnectionGroupBox;
|
||||
private System.Windows.Forms.RadioButton _namedConnectionRadioButton;
|
||||
private System.Windows.Forms.ComboBox _namedConnectionComboBox;
|
||||
private System.Windows.Forms.RadioButton _connectionStringRadioButton;
|
||||
private System.Windows.Forms.TextBox _connectionStringTextBox;
|
||||
private System.Windows.Forms.Label _containerNameLabel;
|
||||
private System.Windows.Forms.ComboBox _containerNameComboBox;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceContainerNameConverter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceContainerNameConverter : StringConverter
|
||||
{
|
||||
|
||||
public EntityDataSourceContainerNameConverter()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
// We can only get a list of possible DefaultContainerName values if we have:
|
||||
// (1) Connection string so we can load metadata
|
||||
// Even if this value is set, it may not be possible to actually load the metadata, but at least we can try the lookup if requested
|
||||
|
||||
EntityDataSource entityDataSource = context.Instance as EntityDataSource;
|
||||
if (entityDataSource != null && !String.IsNullOrEmpty(entityDataSource.ConnectionString))
|
||||
{
|
||||
List<EntityDataSourceContainerNameItem> containerNameItems = new EntityDataSourceDesignerHelper(entityDataSource, false /*interactiveMode*/).GetContainerNames(true /*sortResults*/);
|
||||
string[] containers = new string[containerNameItems.Count];
|
||||
for (int i = 0; i < containerNameItems.Count; i++)
|
||||
{
|
||||
containers[i] = containerNameItems[i].ToString();
|
||||
}
|
||||
return new StandardValuesCollection(containers);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceContainerNameItem.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceContainerNameItem : IComparable<EntityDataSourceContainerNameItem>
|
||||
{
|
||||
// Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly.
|
||||
private readonly EntityContainer _entityContainer; // used when we have a real EntityContainer backing this item
|
||||
private readonly string _unknownContainerName; // used when we have an unknown DefaultContainerName that we still want to include in the list
|
||||
|
||||
internal EntityDataSourceContainerNameItem(EntityContainer entityContainer)
|
||||
{
|
||||
Debug.Assert(entityContainer != null, "null entityContainer");
|
||||
_entityContainer = entityContainer;
|
||||
}
|
||||
|
||||
internal EntityDataSourceContainerNameItem(string unknownContainerName)
|
||||
{
|
||||
Debug.Assert(!String.IsNullOrEmpty(unknownContainerName), "null or empty unknownContainerName");
|
||||
_unknownContainerName = unknownContainerName;
|
||||
}
|
||||
|
||||
internal string EntityContainerName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entityContainer != null)
|
||||
{
|
||||
return _entityContainer.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _unknownContainerName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal EntityContainer EntityContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
// may be null if this represents an unknown container
|
||||
return _entityContainer;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.EntityContainerName;
|
||||
}
|
||||
|
||||
int IComparable<EntityDataSourceContainerNameItem>.CompareTo(EntityDataSourceContainerNameItem other)
|
||||
{
|
||||
return (String.Compare(this.EntityContainerName, other.EntityContainerName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,343 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceDataSelectionPanel.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal partial class EntityDataSourceDataSelectionPanel : WizardPanel
|
||||
{
|
||||
private EntityDataSourceDataSelection _dataSelection;
|
||||
private bool _ignoreEvents; // used when a control is set by the wizard, tells the event handlers to do nothing
|
||||
|
||||
public EntityDataSourceDataSelectionPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeUI();
|
||||
InitializeTabIndexes();
|
||||
}
|
||||
|
||||
#region General Initialization
|
||||
public void Register(EntityDataSourceDataSelection dataSelection)
|
||||
{
|
||||
_dataSelection = dataSelection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Control Initialization
|
||||
private void InitializeSizes()
|
||||
{
|
||||
int top = 0;
|
||||
|
||||
_entitySetLabel.Location = new Point(9, top + 8);
|
||||
_entitySetLabel.Size = new Size(80, 13);
|
||||
top = _entitySetLabel.Bottom;
|
||||
|
||||
_entitySetComboBox.Location = new Point(12, top + 3);
|
||||
_entitySetComboBox.Size = new Size(502, 21);
|
||||
top = _entitySetComboBox.Bottom;
|
||||
|
||||
_entityTypeFilterLabel.Location = new Point(9, top + 6);
|
||||
_entityTypeFilterLabel.Size = new Size(118, 13);
|
||||
top = _entityTypeFilterLabel.Bottom;
|
||||
|
||||
_entityTypeFilterComboBox.Location = new System.Drawing.Point(12, top + 3);
|
||||
_entityTypeFilterComboBox.Size = new System.Drawing.Size(502, 21);
|
||||
top = _entityTypeFilterComboBox.Bottom;
|
||||
|
||||
_selectLabel.Location = new Point(9, top + 6);
|
||||
_selectLabel.Size = new Size(40, 13);
|
||||
top = _selectLabel.Bottom;
|
||||
|
||||
_selectAdvancedTextBox.Location = new Point(12, top + 3);
|
||||
_selectAdvancedTextBox.Multiline = true; // set this here so the size will be set properly
|
||||
_selectAdvancedTextBox.Size = new Size(502, 137);
|
||||
// don't need to set top here because the next control has the same location and size
|
||||
|
||||
_selectSimpleCheckedListBox.Location = _selectAdvancedTextBox.Location;
|
||||
_selectSimpleCheckedListBox.Size = _selectAdvancedTextBox.Size;
|
||||
_selectSimpleCheckedListBox.ColumnWidth = 225;
|
||||
top = _selectSimpleCheckedListBox.Bottom;
|
||||
|
||||
_insertUpdateDeletePanel.Location = new Point(12, top + 3);
|
||||
_insertUpdateDeletePanel.Size = new Size(502, 69);
|
||||
top = 0; // position of rest of controls are relative to this panel
|
||||
|
||||
_enableInsertCheckBox.Location = new Point(3, top + 3);
|
||||
_enableInsertCheckBox.Size = new Size(141, 17);
|
||||
top = _enableInsertCheckBox.Bottom;
|
||||
|
||||
_enableUpdateCheckBox.Location = new Point(3, top + 6);
|
||||
_enableUpdateCheckBox.Size = new Size(149, 17);
|
||||
top = _enableUpdateCheckBox.Bottom;
|
||||
|
||||
_enableDeleteCheckBox.Location = new Point(3, top + 6);
|
||||
_enableDeleteCheckBox.Size = new Size(145, 17);
|
||||
|
||||
// if any controls are added, top should be reset to _insertUpdateDeletePanel.Bottom before adding them here
|
||||
}
|
||||
|
||||
private void InitializeTabIndexes()
|
||||
{
|
||||
_entitySetLabel.TabStop = false;
|
||||
_entitySetComboBox.TabStop = true;
|
||||
_entityTypeFilterLabel.TabStop = false;
|
||||
_entityTypeFilterComboBox.TabStop = true;
|
||||
_selectLabel.TabStop = false;
|
||||
_selectSimpleCheckedListBox.TabStop = true;
|
||||
_selectAdvancedTextBox.TabStop = true;
|
||||
_insertUpdateDeletePanel.TabStop = false;
|
||||
_enableInsertCheckBox.TabStop = true;
|
||||
_enableDeleteCheckBox.TabStop = true;
|
||||
_enableUpdateCheckBox.TabStop = true;
|
||||
|
||||
int tabIndex = 0;
|
||||
|
||||
_entitySetLabel.TabIndex = tabIndex += 10;
|
||||
_entitySetComboBox.TabIndex = tabIndex += 10;
|
||||
_entityTypeFilterLabel.TabIndex = tabIndex += 10;
|
||||
_entityTypeFilterComboBox.TabIndex = tabIndex += 10;
|
||||
_selectLabel.TabIndex = tabIndex += 10;
|
||||
_selectSimpleCheckedListBox.TabIndex = tabIndex += 10;
|
||||
_selectAdvancedTextBox.TabIndex = tabIndex += 10;
|
||||
_insertUpdateDeletePanel.TabIndex = tabIndex += 10;
|
||||
_enableInsertCheckBox.TabIndex = tabIndex += 10;
|
||||
_enableUpdateCheckBox.TabIndex = tabIndex += 10;
|
||||
_enableDeleteCheckBox.TabIndex = tabIndex += 10;
|
||||
}
|
||||
|
||||
private void InitializeUI()
|
||||
{
|
||||
_entitySetLabel.Text = Strings.Wizard_DataSelectionPanel_EntitySetName;
|
||||
_entitySetComboBox.AccessibleName = Strings.Wizard_DataSelectionPanel_EntitySetNameAccessibleName;
|
||||
_entityTypeFilterLabel.Text = Strings.Wizard_DataSelectionPanel_EntityTypeFilter;
|
||||
_entityTypeFilterComboBox.AccessibleName = Strings.Wizard_DataSelectionPanel_EntityTypeFilterAccessibleName;
|
||||
_selectLabel.Text = Strings.Wizard_DataSelectionPanel_Select;
|
||||
_selectSimpleCheckedListBox.AccessibleName = Strings.Wizard_DataSelectionPanel_SelectAccessibleName;
|
||||
_selectAdvancedTextBox.AccessibleName = Strings.Wizard_DataSelectionPanel_SelectAccessibleName;
|
||||
_enableInsertCheckBox.Text = Strings.Wizard_DataSelectionPanel_Insert;
|
||||
_enableInsertCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_InsertAccessibleName;
|
||||
_enableDeleteCheckBox.Text = Strings.Wizard_DataSelectionPanel_Delete;
|
||||
_enableDeleteCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_DeleteAccessibleName;
|
||||
_enableUpdateCheckBox.Text = Strings.Wizard_DataSelectionPanel_Update;
|
||||
_enableUpdateCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_UpdateAccessibleName;
|
||||
this.Caption = Strings.Wizard_DataSelectionPanel_Caption;
|
||||
this.AccessibleName = Strings.Wizard_DataSelectionPanel_Caption;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Control Event Handlers
|
||||
private void OnEnableDeleteCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectEnableDelete(_enableDeleteCheckBox.Checked);
|
||||
// this property has no effect on the wizard, so don't need to update it
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnableInsertCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectEnableInsert(_enableInsertCheckBox.Checked);
|
||||
// this property has no effect on the wizard, so don't need to update it
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnableUpdateCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectEnableUpdate(_enableUpdateCheckBox.Checked);
|
||||
// this property has no effect on the wizard, so don't need to update it
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEntitySetComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectEntitySetName(_entitySetComboBox.SelectedItem as EntityDataSourceEntitySetNameItem);
|
||||
_dataSelection.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEntityTypeFilterComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectEntityTypeFilter(_entityTypeFilterComboBox.SelectedItem as EntityDataSourceEntityTypeFilterItem);
|
||||
_dataSelection.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectAdvancedTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
_dataSelection.SelectAdvancedSelect(_selectAdvancedTextBox.Text);
|
||||
_dataSelection.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectSimpleCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
|
||||
{
|
||||
if (!_ignoreEvents)
|
||||
{
|
||||
if (e.NewValue == CheckState.Checked)
|
||||
{
|
||||
// if any other box is checked except 'Select All (Entity Value)', clear 'Select All (Entity Value)'
|
||||
if (e.Index != 0)
|
||||
{
|
||||
_selectSimpleCheckedListBox.SetItemChecked(0, false);
|
||||
_dataSelection.SelectEnableInsert(false);
|
||||
_dataSelection.SelectEnableUpdate(false);
|
||||
_dataSelection.SelectEnableDelete(false);
|
||||
}
|
||||
// if 'Select All (Entity Value)' is checked, uncheck all others
|
||||
else
|
||||
{
|
||||
// disable events while we bulk clear the selected items
|
||||
_ignoreEvents = true;
|
||||
// this event occurs before the check state is changed on the current selection, so it won't
|
||||
// uncheck the box that triggered this event
|
||||
foreach (int checkedIndex in _selectSimpleCheckedListBox.CheckedIndices)
|
||||
{
|
||||
_selectSimpleCheckedListBox.SetItemChecked(checkedIndex, false);
|
||||
}
|
||||
_ignoreEvents = false;
|
||||
_dataSelection.ClearAllSelectedProperties();
|
||||
}
|
||||
|
||||
// Add the current index to the list of selected properties in temporary state storage
|
||||
_dataSelection.SelectEntityProperty(e.Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove the current index from the list of selected properties in temporary state storage.
|
||||
_dataSelection.DeselectEntityProperty(e.Index);
|
||||
}
|
||||
|
||||
_dataSelection.UpdateInsertUpdateDeleteState();
|
||||
|
||||
// If there are no longer any properties checked at this point, the Finish button will be disabled
|
||||
_dataSelection.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Wizard State Management
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
{
|
||||
base.OnVisibleChanged(e);
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
_dataSelection.UpdateWizardState();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods for setting control values
|
||||
public void SetEnableInsertUpdateDelete(bool enableInsert, bool enableUpdate, bool enableDelete)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_enableInsertCheckBox.Checked = enableInsert;
|
||||
_enableUpdateCheckBox.Checked = enableUpdate;
|
||||
_enableDeleteCheckBox.Checked = enableDelete;
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetEnableInsertUpdateDeletePanel(bool enablePanel)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_insertUpdateDeletePanel.Enabled = enablePanel;
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetEntitySetNames(List<EntityDataSourceEntitySetNameItem> entitySetNames)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_entitySetComboBox.Items.Clear();
|
||||
_entitySetComboBox.Items.AddRange(entitySetNames.ToArray());
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
// Populates the CheckedListBox with the specified entityTypeProperties and checks all of the indexes specified in selectedEntityTypeProperties
|
||||
// Expects that 'Select All (Entity Value)' is in the list of properties already
|
||||
public void SetEntityTypeProperties(List<string> entityTypeProperties, List<int> selectedEntityTypeProperties)
|
||||
{
|
||||
Debug.Assert(entityTypeProperties != null && entityTypeProperties.Count > 0, "unexpected null or empty entityTypeProperties");
|
||||
Debug.Assert(selectedEntityTypeProperties != null && selectedEntityTypeProperties.Count > 0, "unexpected null or empty selectedEntityTypeProperties");
|
||||
|
||||
_ignoreEvents = true;
|
||||
// remove any items currently in the list and replace them with the current list and selected properties
|
||||
_selectSimpleCheckedListBox.Items.Clear();
|
||||
_selectSimpleCheckedListBox.Items.AddRange(entityTypeProperties.ToArray());
|
||||
|
||||
foreach (int entityProperty in selectedEntityTypeProperties)
|
||||
{
|
||||
// check all of the items in the list of selected properties
|
||||
_selectSimpleCheckedListBox.SetItemChecked(entityProperty, true);
|
||||
}
|
||||
|
||||
// Update the controls
|
||||
_selectAdvancedTextBox.Visible = false;
|
||||
_selectSimpleCheckedListBox.Visible = true;
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetEntityTypeFilters(List<EntityDataSourceEntityTypeFilterItem> entityTypeFilters)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_entityTypeFilterComboBox.Items.Clear();
|
||||
_entityTypeFilterComboBox.Items.AddRange(entityTypeFilters.ToArray());
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetSelectedEntityTypeFilter(EntityDataSourceEntityTypeFilterItem selectedEntityTypeFilter)
|
||||
{
|
||||
Debug.Assert(selectedEntityTypeFilter != null, "cannot select null from EntityTypeFilter combobox");
|
||||
|
||||
_ignoreEvents = true;
|
||||
_entityTypeFilterComboBox.SelectedItem = selectedEntityTypeFilter;
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetSelect(string select)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
_selectAdvancedTextBox.Text = select;
|
||||
_selectAdvancedTextBox.Visible = true;
|
||||
_selectSimpleCheckedListBox.Visible = false;
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
|
||||
public void SetSelectedEntitySetName(EntityDataSourceEntitySetNameItem selectedEntitySet)
|
||||
{
|
||||
_ignoreEvents = true;
|
||||
if (selectedEntitySet == null)
|
||||
{
|
||||
_entitySetComboBox.SelectedIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_entitySetComboBox.SelectedItem = selectedEntitySet;
|
||||
}
|
||||
_ignoreEvents = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceDataSelectionPanel.designer.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Windows.Forms;
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
partial class EntityDataSourceDataSelectionPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component 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._entitySetLabel = new System.Windows.Forms.Label();
|
||||
this._entitySetComboBox = new System.Windows.Forms.ComboBox();
|
||||
this._entityTypeFilterLabel = new System.Windows.Forms.Label();
|
||||
this._entityTypeFilterComboBox = new System.Windows.Forms.ComboBox();
|
||||
this._selectLabel = new System.Windows.Forms.Label();
|
||||
this._selectAdvancedTextBox = new System.Windows.Forms.TextBox();
|
||||
this._selectSimpleCheckedListBox = new System.Windows.Forms.CheckedListBox();
|
||||
this._insertUpdateDeletePanel = new System.Windows.Forms.Panel();
|
||||
this._enableInsertCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this._enableDeleteCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this._enableUpdateCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this._insertUpdateDeletePanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.InitializeSizes();
|
||||
|
||||
//
|
||||
// _entitySetLabel
|
||||
//
|
||||
this._entitySetLabel.AutoSize = true;
|
||||
this._entitySetLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._entitySetLabel.Name = "_entitySetLabel";
|
||||
//
|
||||
// _entitySetComboBox
|
||||
//
|
||||
this._entitySetComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this._entitySetComboBox.FormattingEnabled = true;
|
||||
this._entitySetComboBox.Name = "_entitySetComboBox";
|
||||
this._entitySetComboBox.SelectedIndexChanged += new System.EventHandler(this.OnEntitySetComboBox_SelectedIndexChanged);
|
||||
this._entitySetComboBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// _entityTypeFilterLabel
|
||||
//
|
||||
this._entityTypeFilterLabel.AutoSize = true;
|
||||
this._entityTypeFilterLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._entityTypeFilterLabel.Name = "_entityTypeFilterLabel";
|
||||
//
|
||||
// _entityTypeFilterComboBox
|
||||
//
|
||||
this._entityTypeFilterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this._entityTypeFilterComboBox.FormattingEnabled = true;
|
||||
this._entityTypeFilterComboBox.Name = "_entityTypeFilterComboBox";
|
||||
this._entityTypeFilterComboBox.SelectedIndexChanged += new EventHandler(OnEntityTypeFilterComboBox_SelectedIndexChanged);
|
||||
this._entityTypeFilterComboBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
//
|
||||
// _selectLabel
|
||||
//
|
||||
this._selectLabel.AutoSize = true;
|
||||
this._selectLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._selectLabel.Name = "_selectLabel";
|
||||
//
|
||||
// _selectAdvancedTextBox
|
||||
//
|
||||
this._selectAdvancedTextBox.Multiline = true;
|
||||
this._selectAdvancedTextBox.Name = "_selectAdvancedTextBox";
|
||||
this._selectAdvancedTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this._selectAdvancedTextBox.Visible = false;
|
||||
this._selectAdvancedTextBox.TextChanged += new EventHandler(OnSelectAdvancedTextBox_TextChanged);
|
||||
this._selectAdvancedTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
|
||||
//
|
||||
// _selectSimpleCheckedListBox
|
||||
//
|
||||
this._selectSimpleCheckedListBox.CheckOnClick = true;
|
||||
this._selectSimpleCheckedListBox.FormattingEnabled = true;
|
||||
this._selectSimpleCheckedListBox.HorizontalScrollbar = true;
|
||||
this._selectSimpleCheckedListBox.MultiColumn = true;
|
||||
this._selectSimpleCheckedListBox.Name = "_selectSimpleCheckedListBox";
|
||||
this._selectSimpleCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(OnSelectSimpleCheckedListBox_ItemCheck);
|
||||
this._selectSimpleCheckedListBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
|
||||
//
|
||||
// _insertUpdateDeletePanel
|
||||
//
|
||||
this._insertUpdateDeletePanel.Controls.Add(this._enableInsertCheckBox);
|
||||
this._insertUpdateDeletePanel.Controls.Add(this._enableUpdateCheckBox);
|
||||
this._insertUpdateDeletePanel.Controls.Add(this._enableDeleteCheckBox);
|
||||
this._insertUpdateDeletePanel.Name = "_insertUpdateDeletePanel";
|
||||
this._insertUpdateDeletePanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
//
|
||||
// _enableInsertCheckBox
|
||||
//
|
||||
this._enableInsertCheckBox.AutoSize = true;
|
||||
this._enableInsertCheckBox.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._enableInsertCheckBox.Name = "_enableInsertCheckBox";
|
||||
this._enableInsertCheckBox.UseVisualStyleBackColor = true;
|
||||
this._enableInsertCheckBox.CheckedChanged += new EventHandler(OnEnableInsertCheckBox_CheckedChanged);
|
||||
this._enableInsertCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
//
|
||||
// _enableUpdateCheckBox
|
||||
//
|
||||
this._enableUpdateCheckBox.AutoSize = true;
|
||||
this._enableUpdateCheckBox.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._enableUpdateCheckBox.Name = "_enableUpdateCheckBox";
|
||||
this._enableUpdateCheckBox.UseVisualStyleBackColor = true;
|
||||
this._enableUpdateCheckBox.CheckedChanged += new EventHandler(OnEnableUpdateCheckBox_CheckedChanged);
|
||||
this._enableUpdateCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
//
|
||||
// _enableDeleteCheckBox
|
||||
//
|
||||
this._enableDeleteCheckBox.AutoSize = true;
|
||||
this._enableDeleteCheckBox.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this._enableDeleteCheckBox.Name = "_enableDeleteCheckBox";
|
||||
this._enableDeleteCheckBox.UseVisualStyleBackColor = true;
|
||||
this._enableDeleteCheckBox.CheckedChanged += new EventHandler(OnEnableDeleteCheckBox_CheckedChanged);
|
||||
this._enableDeleteCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
|
||||
//
|
||||
// EntityDataSourceDataSelectionPanel
|
||||
//
|
||||
this.Controls.Add(this._entitySetLabel);
|
||||
this.Controls.Add(this._entitySetComboBox);
|
||||
this.Controls.Add(this._entityTypeFilterLabel);
|
||||
this.Controls.Add(this._entityTypeFilterComboBox);
|
||||
this.Controls.Add(this._selectLabel);
|
||||
this.Controls.Add(this._selectSimpleCheckedListBox);
|
||||
this.Controls.Add(this._selectAdvancedTextBox);
|
||||
this.Controls.Add(this._insertUpdateDeletePanel);
|
||||
this.Name = "EntityDataSourceDataSelectionPanel";
|
||||
this.Size = new System.Drawing.Size(528, 319);
|
||||
this.MinimumSize = this.Size;
|
||||
this._insertUpdateDeletePanel.ResumeLayout(false);
|
||||
this._insertUpdateDeletePanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label _entitySetLabel;
|
||||
private System.Windows.Forms.ComboBox _entitySetComboBox;
|
||||
private System.Windows.Forms.Label _entityTypeFilterLabel;
|
||||
private System.Windows.Forms.ComboBox _entityTypeFilterComboBox;
|
||||
private System.Windows.Forms.Label _selectLabel;
|
||||
private System.Windows.Forms.TextBox _selectAdvancedTextBox;
|
||||
private System.Windows.Forms.CheckedListBox _selectSimpleCheckedListBox;
|
||||
private System.Windows.Forms.Panel _insertUpdateDeletePanel;
|
||||
private System.Windows.Forms.CheckBox _enableInsertCheckBox;
|
||||
private System.Windows.Forms.CheckBox _enableDeleteCheckBox;
|
||||
private System.Windows.Forms.CheckBox _enableUpdateCheckBox;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,400 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceDesigner.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
public class EntityDataSourceDesigner : DataSourceDesigner
|
||||
{
|
||||
private EntityDataSourceDesignerHelper _helper;
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
_helper = new EntityDataSourceDesignerHelper(component as EntityDataSource, true /*interactiveMode*/);
|
||||
_helper.AddSystemWebEntityReference();
|
||||
}
|
||||
|
||||
// Whether or not the EntityDataSource can be configured. Currently we have no conditions where you can't at least attempt to
|
||||
// configure it. If there is no metadata available, an error may occur, but you can still try to configure the control.
|
||||
public override bool CanConfigure
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRefreshSchema
|
||||
{
|
||||
get
|
||||
{
|
||||
// Minimum properties required for schema are ConnectionString and DefaultContainerName, plus EntitySetName or CommandText
|
||||
return (!String.IsNullOrEmpty(_helper.ConnectionString) && !String.IsNullOrEmpty(_helper.DefaultContainerName)) &&
|
||||
(!String.IsNullOrEmpty(_helper.EntitySetName) || !String.IsNullOrEmpty(_helper.CommandText));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
{
|
||||
InvokeTransactedChange(Component,
|
||||
new TransactedChangeCallback(ConfigureDataSourceChangeCallback),
|
||||
null, Strings.WizardTransactionDescription);
|
||||
}
|
||||
|
||||
private bool ConfigureDataSourceChangeCallback(object context)
|
||||
{
|
||||
try
|
||||
{
|
||||
SuppressDataSourceEvents();
|
||||
|
||||
IServiceProvider serviceProvider = Component.Site as IServiceProvider;
|
||||
EntityDataSourceWizardForm form = new EntityDataSourceWizardForm(serviceProvider, _helper.LoadEntityDataSourceState(), this);
|
||||
DialogResult result = UIHelper.ShowDialog(serviceProvider, form);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
_helper.SaveEntityDataSourceProperties(form.EntityDataSourceState);
|
||||
|
||||
OnDataSourceChanged(EventArgs.Empty);
|
||||
RefreshSchema(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ResumeDataSourceEvents();
|
||||
}
|
||||
}
|
||||
|
||||
#region Design-time Schema Support
|
||||
public override void RefreshSchema(bool preferSilent)
|
||||
{
|
||||
try
|
||||
{
|
||||
SuppressDataSourceEvents();
|
||||
_helper.RefreshSchema(preferSilent);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ResumeDataSourceEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public override DesignerDataSourceView GetView(string viewName)
|
||||
{
|
||||
return _helper.GetView(viewName);
|
||||
}
|
||||
|
||||
public override string[] GetViewNames()
|
||||
{
|
||||
return _helper.GetViewNames();
|
||||
}
|
||||
|
||||
internal void FireOnDataSourceChanged(EventArgs e)
|
||||
{
|
||||
// Clear metadata first because anything we have cached is now invalid since a property has changed
|
||||
_helper.ClearMetadata();
|
||||
OnDataSourceChanged(e);
|
||||
}
|
||||
|
||||
internal void FireOnSchemaRefreshed(EventArgs e)
|
||||
{
|
||||
OnSchemaRefreshed(e);
|
||||
}
|
||||
|
||||
internal bool InternalViewSchemasEquivalent(IDataSourceViewSchema viewSchema1, IDataSourceViewSchema viewSchema2)
|
||||
{
|
||||
return ViewSchemasEquivalent(viewSchema1, viewSchema2);
|
||||
}
|
||||
|
||||
internal virtual object LoadFromDesignerState(string key)
|
||||
{
|
||||
return DesignerState[key];
|
||||
}
|
||||
|
||||
internal void SaveDesignerState(string key, object value)
|
||||
{
|
||||
DesignerState[key] = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden control properties for providing editors and dropdowns in property grid
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_DefaultContainerName),
|
||||
TypeConverter(typeof(EntityDataSourceContainerNameConverter)),
|
||||
]
|
||||
public string DefaultContainerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.DefaultContainerName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.DefaultContainerName = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_EntitySetName),
|
||||
TypeConverter(typeof(EntityDataSourceEntitySetNameConverter)),
|
||||
]
|
||||
public string EntitySetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.EntitySetName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.EntitySetName = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_EntityTypeFilter),
|
||||
TypeConverter(typeof(EntityDataSourceEntityTypeFilterConverter)),
|
||||
]
|
||||
public string EntityTypeFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.EntityTypeFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.EntityTypeFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_CommandText),
|
||||
DefaultValue(null),
|
||||
Editor(typeof(EntityDataSourceStatementEditor), typeof(UITypeEditor)),
|
||||
MergableProperty(false),
|
||||
]
|
||||
public string CommandText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.CommandText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.CommandText = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_ConnectionString)
|
||||
]
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.ConnectionString;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.ConnectionString = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_OrderBy),
|
||||
DefaultValue(null),
|
||||
Editor(typeof(EntityDataSourceStatementEditor), typeof(UITypeEditor)),
|
||||
MergableProperty(false),
|
||||
]
|
||||
public string OrderBy
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.OrderBy;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.OrderBy = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_Select),
|
||||
DefaultValue(""),
|
||||
Editor(typeof(EntityDataSourceStatementEditor), typeof(UITypeEditor)),
|
||||
MergableProperty(false),
|
||||
]
|
||||
public string Select
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.Select;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.Select = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Category("Data"),
|
||||
ResourceDescription(WebControlsRes.PropertyDescription_Where),
|
||||
DefaultValue(null),
|
||||
Editor(typeof(EntityDataSourceStatementEditor), typeof(UITypeEditor)),
|
||||
MergableProperty(false),
|
||||
]
|
||||
public string Where
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.Where;
|
||||
}
|
||||
set
|
||||
{
|
||||
_helper.Where = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Helper methods to manage properties and parameters in the statement editor
|
||||
internal bool AutoGenerateOrderByClause
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.AutoGenerateOrderByClause;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool AutoGenerateWhereClause
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.AutoGenerateWhereClause;
|
||||
}
|
||||
}
|
||||
|
||||
internal ParameterCollection CloneCommandParameters()
|
||||
{
|
||||
return CloneParameterCollection(_helper.CommandParameters);
|
||||
}
|
||||
|
||||
internal ParameterCollection CloneOrderByParameters()
|
||||
{
|
||||
return CloneParameterCollection(_helper.OrderByParameters);
|
||||
}
|
||||
|
||||
internal ParameterCollection CloneSelectParameters()
|
||||
{
|
||||
return CloneParameterCollection(_helper.SelectParameters);
|
||||
}
|
||||
|
||||
internal ParameterCollection CloneWhereParameters()
|
||||
{
|
||||
return CloneParameterCollection(_helper.WhereParameters);
|
||||
}
|
||||
|
||||
private ParameterCollection CloneParameterCollection(ParameterCollection original)
|
||||
{
|
||||
ParameterCollection clones = new ParameterCollection();
|
||||
CloneParameters(original, clones);
|
||||
return clones;
|
||||
}
|
||||
|
||||
internal void CloneParameters(ParameterCollection originalParameters, ParameterCollection newParameters)
|
||||
{
|
||||
foreach (ICloneable parameter in originalParameters)
|
||||
{
|
||||
Parameter clone = (Parameter)parameter.Clone();
|
||||
RegisterClone(parameter, clone);
|
||||
newParameters.Add(clone);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetCommandParameterContents(ParameterCollection newParams)
|
||||
{
|
||||
SetParameters(_helper.CommandParameters, newParams);
|
||||
}
|
||||
|
||||
internal void SetOrderByParameterContents(ParameterCollection newParams)
|
||||
{
|
||||
SetParameters(_helper.OrderByParameters, newParams);
|
||||
}
|
||||
|
||||
internal void SetSelectParameterContents(ParameterCollection newParams)
|
||||
{
|
||||
SetParameters(_helper.SelectParameters, newParams);
|
||||
}
|
||||
|
||||
internal void SetWhereParameterContents(ParameterCollection newParams)
|
||||
{
|
||||
SetParameters(_helper.WhereParameters, newParams);
|
||||
}
|
||||
|
||||
private void SetParameters(ParameterCollection original, ParameterCollection newParams)
|
||||
{
|
||||
original.Clear();
|
||||
foreach (Parameter parameter in newParams)
|
||||
{
|
||||
original.Add(parameter);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
// Properties that are overridden in the designer because they have custom editors or converters
|
||||
Type designerType = GetType();
|
||||
properties["ConnectionString"] = TypeDescriptor.CreateProperty(designerType, "ConnectionString", typeof(string));
|
||||
properties["DefaultContainerName"] = TypeDescriptor.CreateProperty(designerType, "DefaultContainerName", typeof(string));
|
||||
properties["EntitySetName"] = TypeDescriptor.CreateProperty(designerType, "EntitySetName", typeof(string));
|
||||
properties["EntityTypeFilter"] = TypeDescriptor.CreateProperty(designerType, "EntityTypeFilter", typeof(string));
|
||||
properties["CommandText"] = TypeDescriptor.CreateProperty(designerType, "CommandText", typeof(string));
|
||||
properties["OrderBy"] = TypeDescriptor.CreateProperty(designerType, "OrderBy", typeof(string));
|
||||
properties["Select"] = TypeDescriptor.CreateProperty(designerType, "Select", typeof(string));
|
||||
properties["Where"] = TypeDescriptor.CreateProperty(designerType, "Where", typeof(string));
|
||||
|
||||
// Properties that should be browsable in intellisense, but not visible in the designer property grid
|
||||
properties.Remove("ContextType");
|
||||
}
|
||||
|
||||
internal EntityDataSourceDesignerHelper Helper
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceEntitySetNameConverter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceEntitySetNameConverter : StringConverter
|
||||
{
|
||||
public EntityDataSourceEntitySetNameConverter()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
// We can only get a list of possible EntitySetName values if we have:
|
||||
// (1) Connection string so we can load metadata
|
||||
// (2) DefaultContainerName to give scope to the lookup
|
||||
// Even if these values are set, it may not be possible to actually find them in metadata, but at least we can try the lookup if requested
|
||||
|
||||
EntityDataSource entityDataSource = context.Instance as EntityDataSource;
|
||||
if (entityDataSource != null &&
|
||||
!String.IsNullOrEmpty(entityDataSource.ConnectionString) &&
|
||||
!String.IsNullOrEmpty(entityDataSource.DefaultContainerName))
|
||||
{
|
||||
List<EntityDataSourceEntitySetNameItem> entitySetNameItems = new EntityDataSourceDesignerHelper(entityDataSource, false /*interactiveMode*/).GetEntitySets(entityDataSource.DefaultContainerName);
|
||||
string[] entitySetNames = new string[entitySetNameItems.Count];
|
||||
for (int i = 0; i < entitySetNameItems.Count; i++)
|
||||
{
|
||||
entitySetNames[i] = entitySetNameItems[i].EntitySetName;
|
||||
}
|
||||
return new StandardValuesCollection(entitySetNames);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceEntitySetNameItem.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
|
||||
internal class EntityDataSourceEntitySetNameItem : IComparable<EntityDataSourceEntitySetNameItem>
|
||||
{
|
||||
// Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly.
|
||||
private readonly EntitySet _entitySet; // used when we have a real EntitySet backing this item
|
||||
private readonly string _unknownEntitySetName; // used when we have an unknown EntitySetName that we still want to include in the list
|
||||
|
||||
internal EntityDataSourceEntitySetNameItem(EntitySet entitySet)
|
||||
{
|
||||
_entitySet = entitySet;
|
||||
}
|
||||
|
||||
internal EntityDataSourceEntitySetNameItem(string unknownEntitySetName)
|
||||
{
|
||||
_unknownEntitySetName = unknownEntitySetName;
|
||||
}
|
||||
|
||||
internal string EntitySetName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entitySet != null)
|
||||
{
|
||||
return _entitySet.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _unknownEntitySetName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
internal EntitySet EntitySet
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entitySet;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return EntitySetName;
|
||||
}
|
||||
|
||||
int IComparable<EntityDataSourceEntitySetNameItem>.CompareTo(EntityDataSourceEntitySetNameItem other)
|
||||
{
|
||||
return (String.Compare(this.EntitySetName, other.EntitySetName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceEntityTypeFilterConverter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceEntityTypeFilterConverter : StringConverter
|
||||
{
|
||||
public EntityDataSourceEntityTypeFilterConverter()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
// We can only get a list of possible EntityTypeFilter values if we have:
|
||||
// (1) Connection string so we can load metadata
|
||||
// (2) DefaultContainerName to give scope to the lookup
|
||||
// (3) EntitySetName that exists in DefaultContainerName so we can get its type and derived types
|
||||
// Even if these values are set, it may not be possible to actually find them in metadata, but at least we can try the lookup if requested
|
||||
|
||||
EntityDataSource entityDataSource = context.Instance as EntityDataSource;
|
||||
if (entityDataSource != null &&
|
||||
!String.IsNullOrEmpty(entityDataSource.ConnectionString) &&
|
||||
!String.IsNullOrEmpty(entityDataSource.DefaultContainerName) &&
|
||||
!String.IsNullOrEmpty(entityDataSource.EntitySetName))
|
||||
{
|
||||
List<EntityDataSourceEntityTypeFilterItem> entityTypeFilterItems =
|
||||
new EntityDataSourceDesignerHelper(entityDataSource, false /*interactiveMode*/).GetEntityTypeFilters(
|
||||
entityDataSource.DefaultContainerName, entityDataSource.EntitySetName);
|
||||
|
||||
string[] entityTypeFilters = new string[entityTypeFilterItems.Count];
|
||||
for (int i = 0; i < entityTypeFilterItems.Count; i++)
|
||||
{
|
||||
entityTypeFilters[i] = entityTypeFilterItems[i].EntityTypeName;
|
||||
}
|
||||
return new StandardValuesCollection(entityTypeFilters);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceEntityTypeFilterItem.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
|
||||
internal class EntityDataSourceEntityTypeFilterItem : IComparable<EntityDataSourceEntityTypeFilterItem>
|
||||
{
|
||||
// Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly.
|
||||
private readonly EntityType _entityType; // used when we have a real EntityType backing this item
|
||||
private readonly string _unknownEntityTypeName; // used when we have an unknown EntityTypeFilter that we still want to include in the list
|
||||
|
||||
internal EntityDataSourceEntityTypeFilterItem(EntityType entityType)
|
||||
{
|
||||
_entityType = entityType;
|
||||
}
|
||||
|
||||
internal EntityDataSourceEntityTypeFilterItem(string unknownEntityTypeName)
|
||||
{
|
||||
_unknownEntityTypeName = unknownEntityTypeName;
|
||||
}
|
||||
|
||||
internal string EntityTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entityType != null)
|
||||
{
|
||||
return _entityType.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _unknownEntityTypeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal EntityType EntityType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entityType;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return EntityTypeName;
|
||||
}
|
||||
|
||||
int IComparable<EntityDataSourceEntityTypeFilterItem>.CompareTo(EntityDataSourceEntityTypeFilterItem other)
|
||||
{
|
||||
return (String.Compare(this.EntityTypeName, other.EntityTypeName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceState.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//
|
||||
// Temporary storage for properties set via the wizard
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceState
|
||||
{
|
||||
private string _connectionString;
|
||||
private string _defaultContainerName;
|
||||
private string _entityTypeFilter;
|
||||
private string _entitySetName;
|
||||
private string _select;
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_connectionString == null)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
return _connectionString;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connectionString = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DefaultContainerName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_defaultContainerName == null)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
return _defaultContainerName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_defaultContainerName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableDelete
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool EnableInsert
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool EnableUpdate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string EntitySetName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entitySetName == null)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
return _entitySetName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_entitySetName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string EntityTypeFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entityTypeFilter == null)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
return _entityTypeFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
_entityTypeFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Select
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_select == null)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
return _select;
|
||||
}
|
||||
set
|
||||
{
|
||||
_select = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableFlattening
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceStatementEditor.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Design;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.Design;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceStatementEditor : UITypeEditor
|
||||
{
|
||||
private bool EditQueryChangeCallback(object pair)
|
||||
{
|
||||
// pair.First is a wrapper that contains the EntityDataSource instance and property name being edited
|
||||
// pair.Second contains the value of the property being edited
|
||||
ITypeDescriptorContext context = (ITypeDescriptorContext)((Pair)pair).First;
|
||||
string value = (string)((Pair)pair).Second;
|
||||
|
||||
EntityDataSource entityDataSource = (EntityDataSource)context.Instance;
|
||||
IServiceProvider serviceProvider = entityDataSource.Site;
|
||||
|
||||
IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
|
||||
Debug.Assert(designerHost != null, "Did not get DesignerHost service.");
|
||||
|
||||
EntityDataSourceDesigner designer = (EntityDataSourceDesigner)designerHost.GetDesigner(entityDataSource);
|
||||
|
||||
// Configure the dialog for the specified property and display it
|
||||
return Initialize(designer, entityDataSource, context.PropertyDescriptor.Name, serviceProvider, value);
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
ControlDesigner.InvokeTransactedChange(
|
||||
(IComponent)context.Instance,
|
||||
new TransactedChangeCallback(EditQueryChangeCallback),
|
||||
new Pair(context, value),
|
||||
Strings.ExpressionEditorTransactionDescription);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Determines if the specified property is one that has an associated "AutoGenerateXXXClause" property
|
||||
private static bool GetAutoGen(string operation, EntityDataSourceDesigner entityDataSourceDesigner)
|
||||
{
|
||||
if (String.Equals("Where", operation, StringComparison.Ordinal))
|
||||
{
|
||||
return entityDataSourceDesigner.AutoGenerateWhereClause;
|
||||
}
|
||||
else if (String.Equals("OrderBy", operation, StringComparison.Ordinal))
|
||||
{
|
||||
return entityDataSourceDesigner.AutoGenerateOrderByClause;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
|
||||
// Gets the name of the AutoGenerateXXXProperty associated with the specified property name
|
||||
private static string GetOperationAutoGenerateProperty(string propertyName)
|
||||
{
|
||||
if (String.Equals("Where", propertyName, StringComparison.Ordinal))
|
||||
{
|
||||
return "AutoGenerateWhereClause";
|
||||
}
|
||||
else if (String.Equals("OrderBy", propertyName, StringComparison.Ordinal))
|
||||
{
|
||||
return "AutoGenerateOrderByClause";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Gets the label text or accessible name to display over the textbox for editing the specified property name
|
||||
private static string GetStatementLabel(string propertyName, bool accessible)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case "CommandText":
|
||||
return accessible ? Strings.ExpressionEditor_CommandTextLabelAccessibleName :
|
||||
Strings.ExpressionEditor_CommandTextLabel;
|
||||
case "OrderBy":
|
||||
case "Select":
|
||||
case "Where":
|
||||
return accessible ? Strings.ExpressionEditor_ExpressionStatementLabelAccessibleName(propertyName) :
|
||||
Strings.ExpressionEditor_ExpressionStatementLabel(propertyName);
|
||||
default:
|
||||
Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Gets the F1 help topic for each of the dialogs using the specified property name
|
||||
private static string GetHelpTopic(string propertyName)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case "CommandText": return "net.Asp.EntityDataSource.CommandTextExpression";
|
||||
case "OrderBy": return "net.Asp.EntityDataSource.OrderByExpression";
|
||||
case "Select": return "net.Asp.EntityDataSource.SelectExpression";
|
||||
case "Where": return "net.Asp.EntityDataSource.WhereExpression";
|
||||
default:
|
||||
Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the property name for the parameters property associated with the specified property name
|
||||
private static string GetOperationParameterProperty(string propertyName)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case "CommandText":
|
||||
return "CommandParameters";
|
||||
case "OrderBy":
|
||||
return "OrderByParameters";
|
||||
case "Select":
|
||||
return "SelectParameters";
|
||||
case "Where":
|
||||
return "WhereParameters";
|
||||
default:
|
||||
Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Gets a clone of the parameters collection associated with the specified property name
|
||||
private static ParameterCollection GetParameters(string propertyName, EntityDataSourceDesigner designer)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case "CommandText":
|
||||
return designer.CloneCommandParameters();
|
||||
case "OrderBy":
|
||||
return designer.CloneOrderByParameters();
|
||||
case "Select":
|
||||
return designer.CloneSelectParameters();
|
||||
case "Where":
|
||||
return designer.CloneWhereParameters();
|
||||
default:
|
||||
Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Updates the parameters collection associated with the specified property name
|
||||
private static void SetParameters(string propertyName, EntityDataSourceDesigner designer, ParameterCollection parameters)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case "CommandText":
|
||||
designer.SetCommandParameterContents(parameters);
|
||||
break;
|
||||
case "OrderBy":
|
||||
designer.SetOrderByParameterContents(parameters);
|
||||
break;
|
||||
case "Select":
|
||||
designer.SetSelectParameterContents(parameters);
|
||||
break;
|
||||
case "Where":
|
||||
designer.SetWhereParameterContents(parameters);
|
||||
break;
|
||||
default:
|
||||
Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Configures and displays the editor dialog based on the specified property name
|
||||
private bool Initialize(EntityDataSourceDesigner designer, EntityDataSource entityDataSource, string propertyName, IServiceProvider serviceProvider, string statement)
|
||||
{
|
||||
string propertyParameters = GetOperationParameterProperty(propertyName);
|
||||
string autoGenProperty = GetOperationAutoGenerateProperty(propertyName);
|
||||
bool hasAutoGen = (autoGenProperty != null);
|
||||
bool autoGen = GetAutoGen(propertyName, designer);
|
||||
ParameterCollection parameters = GetParameters(propertyName, designer);
|
||||
string label = GetStatementLabel(propertyName, false);
|
||||
string accessibleName = GetStatementLabel(propertyName, true);
|
||||
string helpTopic = GetHelpTopic(propertyName);
|
||||
|
||||
EntityDataSourceStatementEditorForm form = new EntityDataSourceStatementEditorForm(entityDataSource, serviceProvider,
|
||||
hasAutoGen, autoGen, propertyName, label, accessibleName, helpTopic, statement, parameters);
|
||||
|
||||
DialogResult result = UIHelper.ShowDialog(serviceProvider, form);
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// We use the property descriptors to reset the values to
|
||||
// make sure we clear out any databindings or expressions that
|
||||
// may be set.
|
||||
PropertyDescriptor propDesc = null;
|
||||
|
||||
if (autoGenProperty != null)
|
||||
{
|
||||
propDesc = TypeDescriptor.GetProperties(entityDataSource)[autoGenProperty];
|
||||
propDesc.ResetValue(entityDataSource);
|
||||
propDesc.SetValue(entityDataSource, form.AutoGen);
|
||||
}
|
||||
|
||||
if (propertyName != null)
|
||||
{
|
||||
propDesc = TypeDescriptor.GetProperties(entityDataSource)[propertyName];
|
||||
propDesc.ResetValue(entityDataSource);
|
||||
propDesc.SetValue(entityDataSource, form.Statement);
|
||||
}
|
||||
|
||||
if (propertyParameters != null)
|
||||
{
|
||||
SetParameters(propertyName, designer, form.Parameters);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceStatementEditorForm.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//
|
||||
// Enables a user to edit CommandText, OrderBy, Select, and
|
||||
// Where properties and parameters
|
||||
//------------------------------------------------------------------------------
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Web.UI.Design.WebControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceStatementEditorForm : DesignerForm
|
||||
{
|
||||
private System.Windows.Forms.Panel _checkBoxPanel;
|
||||
private System.Windows.Forms.CheckBox _autoGenerateCheckBox;
|
||||
private System.Windows.Forms.Panel _statementPanel;
|
||||
private System.Windows.Forms.Label _statementLabel;
|
||||
private System.Windows.Forms.TextBox _statementTextBox;
|
||||
private ParameterEditorUserControl _parameterEditorUserControl;
|
||||
private System.Windows.Forms.Button _okButton;
|
||||
private System.Windows.Forms.Button _cancelButton;
|
||||
|
||||
private System.Web.UI.Control _entityDataSource;
|
||||
private ParameterCollection _parameters;
|
||||
|
||||
private string _cachedStatementText;
|
||||
private readonly string _helpTopic;
|
||||
|
||||
public EntityDataSourceStatementEditorForm(System.Web.UI.Control entityDataSource, IServiceProvider serviceProvider,
|
||||
bool hasAutoGen, bool isAutoGen, string propertyName, string statementLabelText, string statementAccessibleName,
|
||||
string helpTopic, string statement, ParameterCollection parameters)
|
||||
: base(serviceProvider)
|
||||
{
|
||||
|
||||
_entityDataSource = entityDataSource;
|
||||
InitializeComponent();
|
||||
InitializeUI(propertyName, statementLabelText, statementAccessibleName);
|
||||
InitializeTabIndexes();
|
||||
InitializeAnchors();
|
||||
|
||||
_helpTopic = helpTopic;
|
||||
|
||||
if (!hasAutoGen)
|
||||
{
|
||||
HideCheckBox();
|
||||
}
|
||||
|
||||
_parameters = parameters;
|
||||
|
||||
_autoGenerateCheckBox.Checked = isAutoGen;
|
||||
_statementPanel.Enabled = !isAutoGen;
|
||||
|
||||
_statementTextBox.Text = statement;
|
||||
_statementTextBox.Select(0, 0);
|
||||
|
||||
List<Parameter> paramList = new List<Parameter>();
|
||||
foreach (Parameter p in parameters)
|
||||
{
|
||||
paramList.Add(p);
|
||||
}
|
||||
_parameterEditorUserControl.AddParameters(paramList.ToArray());
|
||||
|
||||
_cachedStatementText = null;
|
||||
}
|
||||
|
||||
public bool AutoGen
|
||||
{
|
||||
get
|
||||
{
|
||||
return _autoGenerateCheckBox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string HelpTopic
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helpTopic;
|
||||
}
|
||||
}
|
||||
|
||||
public ParameterCollection Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parameters;
|
||||
}
|
||||
}
|
||||
|
||||
public string Statement
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statementTextBox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void HideCheckBox()
|
||||
{
|
||||
_autoGenerateCheckBox.Checked = false;
|
||||
_checkBoxPanel.Visible = false;
|
||||
|
||||
int moveUp = _statementPanel.Location.Y - _checkBoxPanel.Location.Y;
|
||||
|
||||
Point loc = _statementPanel.Location;
|
||||
loc.Y -= moveUp;
|
||||
_statementPanel.Location = loc;
|
||||
|
||||
loc = _parameterEditorUserControl.Location;
|
||||
loc.Y -= moveUp;
|
||||
_parameterEditorUserControl.Location = loc;
|
||||
|
||||
Size size = _parameterEditorUserControl.Size;
|
||||
size.Height += moveUp;
|
||||
_parameterEditorUserControl.Size = size;
|
||||
|
||||
size = this.MinimumSize;
|
||||
size.Height -= moveUp;
|
||||
this.MinimumSize = size;
|
||||
this.Size = size;
|
||||
}
|
||||
|
||||
private void InitializeAnchors()
|
||||
{
|
||||
_checkBoxPanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
_autoGenerateCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
|
||||
_statementPanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
_statementLabel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
_statementTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
|
||||
_parameterEditorUserControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||||
|
||||
_okButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
_cancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
}
|
||||
|
||||
#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._okButton = new System.Windows.Forms.Button();
|
||||
this._cancelButton = new System.Windows.Forms.Button();
|
||||
this._statementLabel = new System.Windows.Forms.Label();
|
||||
this._statementTextBox = new System.Windows.Forms.TextBox();
|
||||
this._autoGenerateCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this._parameterEditorUserControl = (ParameterEditorUserControl)Activator.CreateInstance(typeof(ParameterEditorUserControl), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { ServiceProvider, _entityDataSource }, null);
|
||||
this._checkBoxPanel = new System.Windows.Forms.Panel();
|
||||
this._statementPanel = new System.Windows.Forms.Panel();
|
||||
this._checkBoxPanel.SuspendLayout();
|
||||
this._statementPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
this.InitializeSizes();
|
||||
//
|
||||
// _okButton
|
||||
//
|
||||
this._okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._okButton.Name = "_okButton";
|
||||
this._okButton.Click += new System.EventHandler(this.OnOkButtonClick);
|
||||
//
|
||||
// _cancelButton
|
||||
//
|
||||
this._cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this._cancelButton.Name = "_cancelButton";
|
||||
this._cancelButton.Click += new System.EventHandler(this.OnCancelButtonClick);
|
||||
//
|
||||
// _commandLabel
|
||||
//
|
||||
this._statementLabel.Name = "_commandLabel";
|
||||
//
|
||||
// _statementTextBox
|
||||
//
|
||||
this._statementTextBox.AcceptsReturn = true;
|
||||
this._statementTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._statementTextBox.Multiline = true;
|
||||
this._statementTextBox.Name = "_statementTextBox";
|
||||
this._statementTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
//
|
||||
// _autoGenerateCheckBox
|
||||
//
|
||||
this._autoGenerateCheckBox.CheckAlign = ContentAlignment.TopLeft;
|
||||
this._autoGenerateCheckBox.TextAlign = ContentAlignment.TopLeft;
|
||||
this._autoGenerateCheckBox.Name = "_autoGenerateCheckBox";
|
||||
this._autoGenerateCheckBox.UseVisualStyleBackColor = true;
|
||||
this._autoGenerateCheckBox.CheckedChanged += new EventHandler(OnAutoGenerateCheckBoxCheckedChanged);
|
||||
//
|
||||
// _checkBoxPanel
|
||||
//
|
||||
this._checkBoxPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._checkBoxPanel.Controls.Add(this._autoGenerateCheckBox);
|
||||
this._checkBoxPanel.Name = "_radioPanel";
|
||||
//
|
||||
// _statementPanel
|
||||
//
|
||||
this._statementPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._statementPanel.Controls.Add(this._statementLabel);
|
||||
this._statementPanel.Controls.Add(this._statementTextBox);
|
||||
this._statementPanel.Name = "_statementPanel";
|
||||
//
|
||||
// _parameterEditorUserControl
|
||||
//
|
||||
this._parameterEditorUserControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this._parameterEditorUserControl.Name = "_parameterEditorUserControl";
|
||||
//
|
||||
// EntityDataSourceStatementEditorForm
|
||||
//
|
||||
this.AcceptButton = this._okButton;
|
||||
this.CancelButton = this._cancelButton;
|
||||
this.Controls.Add(this._statementPanel);
|
||||
this.Controls.Add(this._checkBoxPanel);
|
||||
this.Controls.Add(this._cancelButton);
|
||||
this.Controls.Add(this._okButton);
|
||||
this.Controls.Add(this._parameterEditorUserControl);
|
||||
this.Name = "EntityDataSourceStatementEditorForm";
|
||||
this._checkBoxPanel.ResumeLayout(false);
|
||||
this._checkBoxPanel.PerformLayout();
|
||||
this._statementPanel.ResumeLayout(false);
|
||||
this._statementPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
InitializeForm();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitializeSizes()
|
||||
{
|
||||
int top = 0;
|
||||
|
||||
_checkBoxPanel.Location = new Point(12, 12);
|
||||
_checkBoxPanel.Size = new Size(456, 32);
|
||||
_autoGenerateCheckBox.Location = new Point(0, 0);
|
||||
_autoGenerateCheckBox.Size = new Size(456, 30);
|
||||
top = _checkBoxPanel.Bottom;
|
||||
|
||||
_statementPanel.Location = new Point(12, top + 4);
|
||||
_statementPanel.Size = new Size(456, 124);
|
||||
|
||||
top = 0;
|
||||
_statementLabel.Location = new Point(0, 0);
|
||||
_statementLabel.Size = new Size(200, 16);
|
||||
top = _statementLabel.Bottom;
|
||||
|
||||
_statementTextBox.Location = new Point(0, top + 3);
|
||||
_statementTextBox.Size = new Size(456, 78);
|
||||
top = _statementPanel.Bottom;
|
||||
|
||||
_parameterEditorUserControl.Location = new Point(12, top + 5);
|
||||
_parameterEditorUserControl.Size = new Size(460, 216);
|
||||
top = _parameterEditorUserControl.Bottom;
|
||||
|
||||
_okButton.Location = new Point(313, top + 6);
|
||||
_okButton.Size = new Size(75, 23);
|
||||
_cancelButton.Location = new Point(393, top + 6);
|
||||
_cancelButton.Size = new Size(75, 23);
|
||||
top = _cancelButton.Bottom;
|
||||
|
||||
ClientSize = new Size(480, top + 12);
|
||||
MinimumSize = new Size(480 + 8, top + 12 + 27);
|
||||
}
|
||||
|
||||
private void InitializeTabIndexes()
|
||||
{
|
||||
_checkBoxPanel.TabStop = false;
|
||||
_autoGenerateCheckBox.TabStop = true;
|
||||
|
||||
_statementPanel.TabStop = false;
|
||||
_statementLabel.TabStop = false;
|
||||
_statementTextBox.TabStop = true;
|
||||
|
||||
_parameterEditorUserControl.TabStop = true;
|
||||
|
||||
_okButton.TabStop = true;
|
||||
_cancelButton.TabStop = true;
|
||||
|
||||
int tabIndex = 0;
|
||||
|
||||
_checkBoxPanel.TabIndex = tabIndex += 10;
|
||||
_autoGenerateCheckBox.TabIndex = tabIndex += 10;
|
||||
|
||||
_statementPanel.TabIndex = tabIndex += 10;
|
||||
_statementLabel.TabIndex = tabIndex += 10;
|
||||
_statementTextBox.TabIndex = tabIndex += 10;
|
||||
|
||||
_parameterEditorUserControl.TabIndex = tabIndex += 10;
|
||||
|
||||
_okButton.TabIndex = tabIndex += 10;
|
||||
_cancelButton.TabIndex = tabIndex += 10;
|
||||
}
|
||||
|
||||
private void InitializeUI(string propertyName, string labelText, string accessibleName)
|
||||
{
|
||||
this.Text = Strings.ExpressionEditor_Caption;
|
||||
this.AccessibleName = Strings.ExpressionEditor_Caption;
|
||||
_okButton.Text = Strings.OKButton;
|
||||
_okButton.AccessibleName = Strings.OKButtonAccessibleName;
|
||||
_cancelButton.Text = Strings.CancelButton;
|
||||
_cancelButton.AccessibleName = Strings.CancelButtonAccessibleName;
|
||||
_statementLabel.Text = labelText;
|
||||
_statementTextBox.AccessibleName = accessibleName;
|
||||
if (String.Equals(propertyName, "Where", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_autoGenerateCheckBox.Text = Strings.ExpressionEditor_AutoGenerateWhereCheckBox;
|
||||
_autoGenerateCheckBox.AccessibleName = Strings.ExpressionEditor_AutoGenerateWhereCheckBoxAccessibleName;
|
||||
}
|
||||
else if (String.Equals(propertyName, "OrderBy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_autoGenerateCheckBox.Text = Strings.ExpressionEditor_AutoGenerateOrderByCheckBox;
|
||||
_autoGenerateCheckBox.AccessibleName = Strings.ExpressionEditor_AutoGenerateOrderByCheckBoxAccessibleName;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAutoGenerateCheckBoxCheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_autoGenerateCheckBox.Checked)
|
||||
{
|
||||
_cachedStatementText = _statementTextBox.Text;
|
||||
_statementTextBox.Text = null;
|
||||
}
|
||||
else if (!String.IsNullOrEmpty(_cachedStatementText))
|
||||
{
|
||||
_statementTextBox.Text = _cachedStatementText;
|
||||
}
|
||||
_statementPanel.Enabled = !_autoGenerateCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void OnCancelButtonClick(System.Object sender, System.EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnOkButtonClick(System.Object sender, System.EventArgs e)
|
||||
{
|
||||
_parameters.Clear();
|
||||
Parameter[] paramList = _parameterEditorUserControl.GetParameters();
|
||||
foreach (Parameter p in paramList)
|
||||
{
|
||||
_parameters.Add(p);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,102 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDataSourceWizardForm.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//
|
||||
// Containing form for the wizard panels
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Web.UI.Design.WebControls.Util;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
internal class EntityDataSourceWizardForm : WizardForm
|
||||
{
|
||||
private EntityDataSourceState _entityDataSourceState;
|
||||
|
||||
private EntityDataSourceConfigureObjectContext _configureContext;
|
||||
private EntityDataSourceDataSelection _configureDataSelection;
|
||||
private readonly EntityDataSourceDesignerHelper _helper;
|
||||
|
||||
public EntityDataSourceWizardForm(IServiceProvider serviceProvider, EntityDataSourceState entityDataSourceState, EntityDataSourceDesigner entityDataSourceDesigner)
|
||||
: base(serviceProvider)
|
||||
{
|
||||
_entityDataSourceState = entityDataSourceState;
|
||||
this.SetGlyph(new Bitmap(BitmapSelector.GetResourceStream(typeof(EntityDataSourceWizardForm), "EntityDataSourceWizard.bmp")));
|
||||
this.Text = String.Format(CultureInfo.InvariantCulture, Strings.Wizard_Caption(((EntityDataSource)entityDataSourceDesigner.Component).ID));
|
||||
|
||||
_helper = entityDataSourceDesigner.Helper;
|
||||
|
||||
EntityDataSourceConfigureObjectContextPanel contextPanel = new EntityDataSourceConfigureObjectContextPanel();
|
||||
_configureContext = new EntityDataSourceConfigureObjectContext(contextPanel, this, entityDataSourceDesigner.Helper, _entityDataSourceState);
|
||||
|
||||
EntityDataSourceDataSelectionPanel dataPanel = new EntityDataSourceDataSelectionPanel();
|
||||
_configureDataSelection = new EntityDataSourceDataSelection(dataPanel, this, entityDataSourceDesigner.Helper, _entityDataSourceState);
|
||||
|
||||
_configureContext.ContainerNameChanged += _configureDataSelection.ContainerNameChangedHandler;
|
||||
|
||||
_configureContext.LoadState();
|
||||
_configureDataSelection.LoadState();
|
||||
|
||||
// Adds the panels to the wizard
|
||||
SetPanels(new WizardPanel[] {
|
||||
contextPanel,
|
||||
dataPanel});
|
||||
}
|
||||
|
||||
protected override string HelpTopic
|
||||
{
|
||||
get
|
||||
{
|
||||
return "net.Asp.EntityDataSource.ConfigureDataSource";
|
||||
}
|
||||
}
|
||||
|
||||
public EntityDataSourceState EntityDataSourceState
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entityDataSourceState;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnFinishButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
_configureContext.SaveState();
|
||||
_configureDataSelection.SaveState();
|
||||
base.OnFinishButtonClick(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(System.Windows.Forms.FormClosedEventArgs e)
|
||||
{
|
||||
// Reset the helper so it knows to try to load the web.config file again on future executions
|
||||
_helper.CanLoadWebConfig = true;
|
||||
base.OnFormClosed(e);
|
||||
}
|
||||
|
||||
public void SetCanFinish(bool enabled)
|
||||
{
|
||||
FinishButton.Enabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
this.AcceptButton = FinishButton;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCanNext(bool enabled)
|
||||
{
|
||||
NextButton.Enabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
this.AcceptButton = NextButton;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EntityDesignerDataSourceView.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//------------------------------------------------------------------------------
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Web.UI.Design;
|
||||
|
||||
namespace System.Web.UI.Design.WebControls
|
||||
{
|
||||
public class EntityDesignerDataSourceView : DesignerDataSourceView
|
||||
{
|
||||
private EntityDataSourceDesignerHelper _helper;
|
||||
|
||||
public EntityDesignerDataSourceView(EntityDataSourceDesigner owner)
|
||||
: base(owner, EntityDataSourceDesignerHelper.DefaultViewName)
|
||||
{
|
||||
_helper = owner.Helper;
|
||||
}
|
||||
|
||||
public override bool CanDelete
|
||||
{
|
||||
get
|
||||
{
|
||||
return CanModify && _helper.EnableDelete;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanInsert
|
||||
{
|
||||
get
|
||||
{
|
||||
return CanModify && _helper.EnableInsert;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool CanModify
|
||||
{
|
||||
get
|
||||
{
|
||||
return !String.IsNullOrEmpty(_helper.EntitySetName) &&
|
||||
String.IsNullOrEmpty(_helper.Select) &&
|
||||
String.IsNullOrEmpty(_helper.CommandText) &&
|
||||
String.IsNullOrEmpty(_helper.GroupBy);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.CanPage;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanSort
|
||||
{
|
||||
get
|
||||
{
|
||||
return _helper.CanSort;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return CanModify && _helper.EnableUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
public override IDataSourceViewSchema Schema
|
||||
{
|
||||
get
|
||||
{
|
||||
DataTable schemaTable = _helper.LoadSchema();
|
||||
if (schemaTable == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new DataSetViewSchema(schemaTable);
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData)
|
||||
{
|
||||
DataTable schemaTable = _helper.LoadSchema();
|
||||
if (schemaTable != null)
|
||||
{
|
||||
isSampleData = true;
|
||||
return DesignTimeData.GetDesignTimeDataSource(DesignTimeData.CreateSampleDataTable(new DataView(schemaTable), true), minimumRows);
|
||||
}
|
||||
|
||||
// Couldn't find design-time schema, use base implementation
|
||||
return base.GetDesignTimeData(minimumRows, out isSampleData);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user