Browse Source

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

pull/37/head
Peter Forstmeier 13 years ago
parent
commit
7ebf7f6881
  1. 2
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml
  2. 6
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml.cs
  3. 96
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/DisplayBinding/EDMDesignerViewContent.cs
  4. 25
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs
  5. 3
      src/Main/Base/Project/Src/Services/File/FileService.cs

2
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml

@ -84,7 +84,7 @@
<TextBlock Grid.Row="5" Margin="3">Database:</TextBlock> <TextBlock Grid.Row="5" Margin="3">Database:</TextBlock>
<ComboBox x:Name="cboDatabases" Grid.Row="5" Grid.Column="1" Margin="3" SelectedItem="{Binding SelectedDatabase, ElementName=This}" <ComboBox x:Name="cboDatabases" Grid.Row="5" Grid.Column="1" Margin="3" SelectedItem="{Binding SelectedDatabase, ElementName=This}"
ItemsSource="{Binding SelectedDatasource.Databases, ElementName=This}" SelectionChanged="cboDatabases_SelectionChanged"> ItemsSource="{Binding SelectedDatasource.Databases, ElementName=This}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Name}" />

6
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml.cs

@ -92,6 +92,7 @@ namespace ICSharpCode.Data.Core.UI.Windows
set set
{ {
_selectedDatabase = value; _selectedDatabase = value;
btnAdd.IsEnabled = (_selectedDatabase != null);
OnPropertyChanged("SelectedDatabase"); OnPropertyChanged("SelectedDatabase");
} }
} }
@ -212,11 +213,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
} }
} }
private void cboDatabases_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
btnAdd.IsEnabled = true;
}
private void btnAdd_Click(object sender, RoutedEventArgs e) private void btnAdd_Click(object sender, RoutedEventArgs e)
{ {
if (_addAction == null) if (_addAction == null)

96
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/DisplayBinding/EDMDesignerViewContent.cs

@ -1,9 +1,8 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System; using System;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -13,7 +12,10 @@ using System.Windows.Data;
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Common;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.ChangeWatcher;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Property; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Property;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type;
using ICSharpCode.Data.EDMDesigner.Core.IO; using ICSharpCode.Data.EDMDesigner.Core.IO;
@ -23,33 +25,24 @@ using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.CSDLType;
using ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard; using ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.ChangeWatcher;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Common;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
#endregion
namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
{ {
public class EDMDesignerViewContent : AbstractViewContent, IHasPropertyContainer, IToolsHost, IEDMDesignerChangeWatcherObserver public class EDMDesignerViewContent : AbstractViewContent, IHasPropertyContainer, IToolsHost, IEDMDesignerChangeWatcherObserver
{ {
#region Fields private ScrollViewer _scrollViewer = new ScrollViewer() {
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
private ScrollViewer _scrollViewer = new ScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; VerticalScrollBarVisibility = ScrollBarVisibility.Auto
};
private DesignerCanvas _designerCanvas = null; private DesignerCanvas _designerCanvas = null;
private PropertyContainer _propertyContainer = new PropertyContainer(); private PropertyContainer _propertyContainer = new PropertyContainer();
private EDMView _edmView = null; private EDMView _edmView = null;
private object _selection = null; private object _selection = null;
#endregion public object Selection {
#region Properties
public object Selection
{
get { return _selection; } get { return _selection; }
set set {
{
if (_selection == null) if (_selection == null)
_propertyContainer.Clear(); _propertyContainer.Clear();
else else
@ -59,30 +52,22 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
} }
} }
public Window Window public Window Window {
{
get { return Application.Current.MainWindow; } get { return Application.Current.MainWindow; }
} }
public EDMView EDMView public EDMView EDMView {
{
get { return _edmView; } get { return _edmView; }
} }
public override object Control public override object Control {
{
get { return _scrollViewer; } get { return _scrollViewer; }
} }
public DesignerCanvas DesignerCanvas public DesignerCanvas DesignerCanvas {
{
get { return _designerCanvas; } get { return _designerCanvas; }
} }
#endregion
#region Constructor
public EDMDesignerViewContent(OpenedFile primaryFile) public EDMDesignerViewContent(OpenedFile primaryFile)
: base(primaryFile) : base(primaryFile)
{ {
@ -94,10 +79,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
EDMDesignerChangeWatcher.AddEDMDesignerViewContent(this); EDMDesignerChangeWatcher.AddEDMDesignerViewContent(this);
} }
#endregion
#region Methods
public override void Load(OpenedFile file, Stream stream) public override void Load(OpenedFile file, Stream stream)
{ {
Debug.Assert(file == this.PrimaryFile); Debug.Assert(file == this.PrimaryFile);
@ -110,17 +91,13 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
_edmView = new EDMView(stream, readMoreAction); _edmView = new EDMView(stream, readMoreAction);
// If EDMX is empty run EDM Wizard // If EDMX is empty run EDM Wizard
if (_edmView.EDM.IsEmpty) if (_edmView.EDM.IsEmpty) {
{
edmxElement = null; edmxElement = null;
string ns = String.Empty; string ns = String.Empty;
if (ProjectService.CurrentProject == null) if (ProjectService.CurrentProject == null) {
{
ns = ICSharpCode.Core.MessageService.ShowInputBox("EDMDesigner","Enter NameSpace","DefaultNamespace"); ns = ICSharpCode.Core.MessageService.ShowInputBox("EDMDesigner","Enter NameSpace","DefaultNamespace");
} } else {
else
{
ns = ProjectService.CurrentProject.RootNamespace; ns = ProjectService.CurrentProject.RootNamespace;
} }
@ -137,8 +114,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
XElement designerViewsElement = null; XElement designerViewsElement = null;
if (edmxElement == null || (designerViewsElement = EDMXIO.ReadSection(edmxElement, EDMXIO.EDMXSection.DesignerViews)) == null) if (edmxElement == null || (designerViewsElement = EDMXIO.ReadSection(edmxElement, EDMXIO.EDMXSection.DesignerViews)) == null) {
{
designerViewsElement = DesignerIO.GenerateNewDesignerViewsFromCSDLView(_edmView); designerViewsElement = DesignerIO.GenerateNewDesignerViewsFromCSDLView(_edmView);
} }
@ -152,11 +128,15 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
_scrollViewer.Content = _designerCanvas; _scrollViewer.Content = _designerCanvas;
// Register CSDL of EDMX in CSDL DatabaseTreeView // Register CSDL of EDMX in CSDL DatabaseTreeView
CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Add(_edmView.CSDL); CSDLViews.Add(_edmView.CSDL);
EDMDesignerChangeWatcher.Init = false; EDMDesignerChangeWatcher.Init = false;
} }
ObservableCollection<CSDLView> CSDLViews {
get { return CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews; }
}
public override void Save(OpenedFile file, Stream stream) public override void Save(OpenedFile file, Stream stream)
{ {
EDMXIO.WriteXDocument(_edmView).Save(stream); EDMXIO.WriteXDocument(_edmView).Save(stream);
@ -164,7 +144,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
private EDMWizardWindow RunWizard(OpenedFile file, string projectStandardNamespace) private EDMWizardWindow RunWizard(OpenedFile file, string projectStandardNamespace)
{ {
EDMWizardWindow wizard = new EDMWizardWindow(file, projectStandardNamespace); var wizard = new EDMWizardWindow(file, projectStandardNamespace);
wizard.Owner = Application.Current.MainWindow; wizard.Owner = Application.Current.MainWindow;
wizard.WindowStartupLocation = WindowStartupLocation.CenterOwner; wizard.WindowStartupLocation = WindowStartupLocation.CenterOwner;
wizard.ShowDialog(); wizard.ShowDialog();
@ -174,21 +154,20 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
public override void Dispose() public override void Dispose()
{ {
if (CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Contains(_edmView.CSDL)) if (_edmView != null) {
CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Remove(_edmView.CSDL); CSDLViews.Remove(_edmView.CSDL);
}
EDMDesignerChangeWatcher.RemoveEDMDesignerViewContent(this); EDMDesignerChangeWatcher.RemoveEDMDesignerViewContent(this);
} }
public void ShowMappingTab(IUIType uiType) public void ShowMappingTab(IUIType uiType)
{ } {
}
#endregion
#region IHasPropertyContainer #region IHasPropertyContainer
public PropertyContainer PropertyContainer public PropertyContainer PropertyContainer {
{
get { return _propertyContainer; } get { return _propertyContainer; }
} }
@ -196,8 +175,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
#region IToolsHost #region IToolsHost
object IToolsHost.ToolsContent object IToolsHost.ToolsContent {
{
get { return null; } get { return null; }
} }
@ -207,18 +185,14 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
public bool ObjectChanged(object changedObject) public bool ObjectChanged(object changedObject)
{ {
foreach (DesignerView designerView in _edmView.DesignerViews) foreach (DesignerView designerView in _edmView.DesignerViews) {
{ foreach (ITypeDesigner uiType in designerView) {
foreach (ITypeDesigner uiType in designerView) if (uiType == changedObject || uiType.UIType.BusinessInstance == changedObject) {
{
if (uiType == changedObject || uiType.UIType.BusinessInstance == changedObject)
{
PrimaryFile.IsDirty = true; PrimaryFile.IsDirty = true;
return true; return true;
} }
} }
} }
return false; return false;
} }

25
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs

@ -25,10 +25,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
{ {
public class MSLIO : IO public class MSLIO : IO
{ {
#region Methods
#region Read
public static XDocument GenerateTypeMapping(XDocument mslDocument) public static XDocument GenerateTypeMapping(XDocument mslDocument)
{ {
XElement mappingElement = mslDocument.Element(XName.Get("Mapping", mslNamespace.NamespaceName)); XElement mappingElement = mslDocument.Element(XName.Get("Mapping", mslNamespace.NamespaceName));
@ -41,8 +37,10 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
if (entityContainerMappingElement == null || entityContainerMappingElement.IsEmpty) if (entityContainerMappingElement == null || entityContainerMappingElement.IsEmpty)
return null; return null;
foreach (XElement entitySetMapping in entityContainerMappingElement.Elements(mslNamespace + "EntitySetMapping")) foreach (XElement entitySetMapping in entityContainerMappingElement.Elements(mslNamespace + "EntitySetMapping")) {
{ if (entitySetMapping.HasEntityTypeMappingChildElement())
continue;
string name = entitySetMapping.Attribute("Name").Value; string name = entitySetMapping.Attribute("Name").Value;
string storeEntitySet = entitySetMapping.Attribute("StoreEntitySet").Value; string storeEntitySet = entitySetMapping.Attribute("StoreEntitySet").Value;
string typeName = entitySetMapping.Attribute("TypeName").Value; string typeName = entitySetMapping.Attribute("TypeName").Value;
@ -61,7 +59,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
return mslDocument; return mslDocument;
} }
public static CSDLContainer IntegrateMSLInCSDLContainer(CSDLContainer csdlContainer, SSDLContainer ssdlContainer, XElement edmxRuntime) public static CSDLContainer IntegrateMSLInCSDLContainer(CSDLContainer csdlContainer, SSDLContainer ssdlContainer, XElement edmxRuntime)
{ {
XElement mappingsElement = edmxRuntime.Element(XName.Get("Mappings", edmxNamespace.NamespaceName)); XElement mappingsElement = edmxRuntime.Element(XName.Get("Mappings", edmxNamespace.NamespaceName));
@ -263,10 +261,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
} }
} }
#endregion
#region Write
public static XElement Write(EDM edm) public static XElement Write(EDM edm)
{ {
CSDLContainer csdlContainer = edm.CSDLContainer; CSDLContainer csdlContainer = edm.CSDLContainer;
@ -533,10 +527,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
new XAttribute("ColumnName", result.Value)); new XAttribute("ColumnName", result.Value));
} }
} }
#endregion
#endregion
} }
#region Extension methods #region Extension methods
@ -560,6 +550,11 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
return element; return element;
} }
public static bool HasEntityTypeMappingChildElement(this XElement entitySetMapping)
{
return entitySetMapping.Elements().Any(e => e.Name.LocalName == "EntityTypeMapping");
}
} }
#endregion #endregion

3
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -149,7 +149,8 @@ namespace ICSharpCode.SharpDevelop
if (openedFileDict.ContainsKey(newName)) { if (openedFileDict.ContainsKey(newName)) {
OpenedFile oldFile = openedFileDict[newName]; OpenedFile oldFile = openedFileDict[newName];
if (oldFile.CurrentView != null) { if (oldFile.CurrentView != null) {
oldFile.CurrentView.WorkbenchWindow.CloseWindow(true); if (oldFile.CurrentView.WorkbenchWindow != null)
oldFile.CurrentView.WorkbenchWindow.CloseWindow(true);
} else { } else {
throw new ArgumentException("there already is a file with the newName"); throw new ArgumentException("there already is a file with the newName");
} }

Loading…
Cancel
Save