Browse Source

Rearrange Messages, cleanup

pull/23/head
PeterForstmeier 14 years ago
parent
commit
abd2ca7ac4
  1. 173
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceDialog.xaml
  2. 214
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceViewModel.cs
  3. 17
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs

173
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceDialog.xaml

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
xmlns:web="clr-namespace:System.Web.Services.Description;assembly=System.Web.Services"
WindowStartupLocation="CenterOwner"
Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
Height="570"
Height="600"
Width="700"
Title="{Binding Title}">
@ -26,99 +26,106 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052 @@ -26,99 +26,106 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052
</HierarchicalDataTemplate>
</Window.Resources>
<!-- Style="{x:Static core:GlobalStyles.ButtonStyle}" -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="5"></RowDefinition>
<RowDefinition Height="7*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox Grid.ColumnSpan="3"
Margin="4,0,4,0"
TextWrapping="Wrap"
Text="To see a list of available services on an specific Server,&#xD;&#xA;&#x9;&#x9;&#x9;enter a service URL and click Go.To browse for available services cklick Discover"></TextBox>
<TextBlock Grid.Row="1" Text="Address:" Margin="4,0,4,0"></TextBlock>
<ComboBox
Grid.Row="2"
Grid.ColumnSpan="2"
Margin="4,0,4,0"
IsEditable="True"
ItemsSource="{Binding MruServices}"
IsSynchronizedWithCurrentItem="True"
LostFocus="Cbo_LostFocus"
SelectedItem="{Binding SelectedService, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
<StackPanel Grid.Column="2"
Grid.Row="2"
Margin="4,0,4,0"
Orientation="Horizontal">
<Button
Content="Go"
Width="30"
Margin="4,0,2,0"
HorizontalContentAlignment="Center"
Command="{Binding GoCommand}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"/>
<Button
Content="Discover"
Margin="2,0,0,0"
HorizontalContentAlignment="Center"
Command="{Binding DiscoverCommand}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"/>
</StackPanel>
<TextBlock Grid.Row="3" Text="Service:" Margin="4,0,4,0"></TextBlock>
TextWrapping="Wrap"
Text="{Binding HeadLine}">
</TextBox>
<TextBlock Grid.Row="1" Text="Address:" Margin="5,0,4,0" VerticalAlignment="Bottom"></TextBlock>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox
Margin="4,0,4,0"
IsEditable="True"
ItemsSource="{Binding MruServices}"
IsSynchronizedWithCurrentItem="True"
LostFocus="Cbo_LostFocus"
SelectedItem="{Binding SelectedService, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
<widgets:UniformGridWithSpacing
Columns="2"
Grid.Column="1"
HorizontalAlignment="Left"
Margin="4,0,4,0">
<Button
Content="Go" HorizontalContentAlignment="Center"
Command="{Binding GoCommand}" />
<Button
Content="Discover" HorizontalContentAlignment="Center"
Command="{Binding DiscoverCommand}" />
</widgets:UniformGridWithSpacing>
</Grid>
<TreeView
Grid.Row="4" Margin="4"
<!-- main area -->
<Grid Grid.Row="4" >
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="Service:" Margin="4,0,4,0"></TextBlock>
<TextBlock Grid.Column="1" Text="Service:" Margin="4,0,4,0"></TextBlock>
<TreeView
Grid.Row="1"
Grid.Column="0"
Margin="4"
Name="tree"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding Path=ServiceItems}"
ItemTemplate="{StaticResource HeaderTemplate}"
SelectedItemChanged="Tree_SelectedItemChanged">
</TreeView>
<GridSplitter
Grid.Column="0"
Grid.Row="4"
Width="2"/>
<ListView
Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Margin="4"
ItemsSource="{Binding Path=TwoValues}">
<ListView.View>
<GridView>
<GridViewColumn Header="Poperty" Width="150" DisplayMemberBinding="{Binding LeftValue}"></GridViewColumn>
<GridViewColumn Header="Value" Width="150" DisplayMemberBinding="{Binding RightValue}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</TreeView>
<GridSplitter
Grid.Row="1"
Grid.Column="0"
Width="2"/>
<ListView
Grid.Column="1" Grid.Row="1" Margin="4"
ItemsSource="{Binding Path=TwoValues}">
<ListView.View>
<GridView>
<GridViewColumn Header="Poperty" Width="150" DisplayMemberBinding="{Binding LeftValue}"></GridViewColumn>
<GridViewColumn Header="Value" Width="150" DisplayMemberBinding="{Binding RightValue}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
<Border Grid.Row="5" Grid.ColumnSpan="3" Margin="4,0,4,0" BorderThickness="2" BorderBrush="LightGray">
<TextBlock></TextBlock>
<TextBlock Text="{Binding ServiceDescriptionMessage}"></TextBlock>
</Border>
<TextBlock Grid.Row="6" Text="NameSpace:" Margin="4,0,4,0"></TextBlock>
<TextBox Grid.Row="7" Grid.ColumnSpan="3" Margin="4"></TextBox>
<TextBlock Grid.Row="6" Text="NameSpace:" Margin="4,0,4,0" VerticalAlignment="Bottom"></TextBlock>
<TextBox Grid.Row="7" Grid.ColumnSpan="3"
Margin="4" Background="White"
Text="{Binding DefaultNameSpace}">
</TextBox>
<widgets:UniformGridWithSpacing
Columns="2"
@ -139,25 +146,5 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052 @@ -139,25 +146,5 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="cancelButtonClick" />
</widgets:UniformGridWithSpacing>
<!--
<widgets:UniformGridWithSpacing Background="Green"
Columns="3"
Grid.Column="2"
Margin="4,4,12,12"
HorizontalAlignment="Center">
<Button
Content="Go" HorizontalContentAlignment="Center"
Command="{Binding GoCommand}" />
<Button
Content="Discover" HorizontalContentAlignment="Center"
Command="{Binding DiscoverCommand}" />
</widgets:UniformGridWithSpacing>
</Grid>
</Grid>
-->
</Grid>
</Window>

214
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceViewModel.cs

@ -38,13 +38,33 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -38,13 +38,33 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
string header1 = "To see a list of available services on an specific Server, ";
string header2 = "enter a service URL and click Go. To browse for available services click Discover";
string noUrl = "Please enter the address of the Service.";
// string discoverMenu ="Services in Solution";
string title = "Add Service Reference";
string defaultNameSpace;
string serviceDescriptionMessage;
string namespacePrefix = String.Empty;
private ObservableCollection<TwoValue> twoValues;
private List<string> mruServices = new List<string>();
private string selectedService;
private IProject project;
List<ServiceItem> items = new List <ServiceItem>();
ServiceItem myItem;
Uri discoveryUri;
ServiceDescriptionCollection serviceDescriptionCollection = new ServiceDescriptionCollection();
CredentialCache credentialCache = new CredentialCache();
WebServiceDiscoveryClientProtocol discoveryClientProtocol;
delegate DiscoveryDocument DiscoverAnyAsync(string url);
delegate void DiscoveredWebServicesHandler(DiscoveryClientProtocol protocol);
delegate void AuthenticationHandler(Uri uri, string authenticationType);
public AddServiceReferenceViewModel(IProject project)
{
Project = project;
title = "Add Service Reference";
project = project;
discoverButtonContend = "Disvover";
HeadLine = header1 + header2;
@ -56,70 +76,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -56,70 +76,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
TwoValues = new ObservableCollection<TwoValue>();
}
private string art;
public string Art {
get { return art; }
set { art = value;
base.RaisePropertyChanged(() =>Art);
}
}
private string title;
public string Title
{
get {return title;}
set {title = value;
base.RaisePropertyChanged(() =>Title);
}
}
public string HeadLine {get; private set;}
private string discoverButtonContend;
public string DiscoverButtonContend {
get { return discoverButtonContend; }
set { discoverButtonContend = value;
base.RaisePropertyChanged(() =>DiscoverButtonContend);}
}
private IProject project;
public IProject Project
{
get {return project;}
set {project = value;
base.RaisePropertyChanged(() =>Project);
}
}
#region Create List of services
private List<string> mruServices = new List<string>();
public List<string> MruServices {
get {
return mruServices; }
set { mruServices = value;
base.RaisePropertyChanged(() =>MruServices);
}
}
private string selectedService;
public string SelectedService {
get { return selectedService; }
set { selectedService = value;
base.RaisePropertyChanged(() =>SelectedService);}
}
#endregion
#region Go
@ -134,6 +90,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -134,6 +90,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
StartDiscovery(uri, new DiscoveryNetworkCredential(CredentialCache.DefaultNetworkCredentials, DiscoveryNetworkCredential.DefaultAuthenticationType));
}
private bool CanExecuteGo()
{
return true;
@ -142,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -142,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
#endregion
#region Discover
#region Discover Command
public System.Windows.Input.ICommand DiscoverCommand {get;private set;}
@ -161,17 +118,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -161,17 +118,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
#region discover service Code from Matt
CredentialCache credentialCache = new CredentialCache();
WebServiceDiscoveryClientProtocol discoveryClientProtocol;
// ICSharpCode.SharpDevelop.Gui.WebReference webReference;
string namespacePrefix = String.Empty;
delegate DiscoveryDocument DiscoverAnyAsync(string url);
delegate void DiscoveredWebServicesHandler(DiscoveryClientProtocol protocol);
delegate void AuthenticationHandler(Uri uri, string authenticationType);
void StartDiscovery(Uri uri, DiscoveryNetworkCredential credential)
{
// Abort previous discovery.
@ -262,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -262,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
}
void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
{
NetworkCredential matchedCredential = credentialCache.GetCredential(uri, credential.AuthenticationType);
if (matchedCredential != null) {
@ -275,22 +221,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -275,22 +221,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
void DiscoveredWebServices(DiscoveryClientProtocol protocol)
{
if (protocol != null) {
// webServicesView.Add(GetServiceDescriptions(protocol));
serviceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol);
ServiceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol);
FillItems (ServiceDescriptionCollection);
var defaultNameSpace = GetDefaultNamespace();
ServiceDescriptionMessage = String.Format("{0} service(s) found at address {1}",
serviceDescriptionCollection.Count,
discoveryUri);
DefaultNameSpace = GetDefaultNamespace();
FillItems (serviceDescriptionCollection);
var referenceName = GetReferenceName(discoveryUri);
/*
webReference = new ICSharpCode.SharpDevelop.Gui.WebReference(project,
discoveryUri.AbsoluteUri,
defaultNameSpace,
referenceName, protocol);
*/
}
else
{
// webReference = null;
}
}
@ -315,35 +253,47 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -315,35 +253,47 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
return uri.Host;
}
return String.Empty;
/*
if (discoveryUri != null) {
return discoveryUri.Host;
}
return String.Empty;
*/
}
#endregion
ServiceDescriptionCollection serviceDescriptionCollection = new ServiceDescriptionCollection();
public ServiceDescriptionCollection ServiceDescriptionCollection
#region new binding
public string Title
{
get {
return serviceDescriptionCollection;
}
set
{
serviceDescriptionCollection = value;
RaisePropertyChanged(() =>ServiceDescriptionCollection);
get {return title;}
set {title = value;
base.RaisePropertyChanged(() =>Title);
}
}
#endregion
public string HeadLine {get; set;}
#region new binding
private string discoverButtonContend;
List<ServiceItem> items = new List <ServiceItem>();
public string DiscoverButtonContend {
get { return discoverButtonContend; }
set { discoverButtonContend = value;
base.RaisePropertyChanged(() =>DiscoverButtonContend);}
}
public List<string> MruServices {
get {
return mruServices; }
set { mruServices = value;
base.RaisePropertyChanged(() =>MruServices);
}
}
public string SelectedService {
get { return selectedService; }
set { selectedService = value;
base.RaisePropertyChanged(() =>SelectedService);}
}
public List <ServiceItem> ServiceItems {
@ -356,8 +306,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -356,8 +306,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
}
ServiceItem myItem;
public ServiceItem ServiceItem {
get { return myItem; }
set { myItem = value;
@ -367,7 +315,20 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -367,7 +315,20 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
}
private ObservableCollection<TwoValue> twoValues;
public string ServiceDescriptionMessage {
get { return serviceDescriptionMessage; }
set { serviceDescriptionMessage = value;
base.RaisePropertyChanged(() =>ServiceDescriptionMessage);
}
}
public string DefaultNameSpace {
get { return defaultNameSpace; }
set { defaultNameSpace = value;
base.RaisePropertyChanged(() =>DefaultNameSpace);}
}
public ObservableCollection<TwoValue> TwoValues {
get { return twoValues; }
@ -378,7 +339,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -378,7 +339,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
}
public void UpdateListView ()
void UpdateListView ()
{
TwoValues.Clear();
string l;
@ -440,14 +401,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -440,14 +401,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
{
Add (element);
}
}
void Add(ServiceDescription description)
{
List<ServiceItem> l = new List<ServiceItem>();
var rootNode = new ServiceItem(GetName(description));
var name = ServiceReferenceHelper.GetServiceName(description);
var rootNode = new ServiceItem(name);
rootNode.Tag = description;
l.Add(rootNode);
@ -480,24 +441,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog @@ -480,24 +441,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
ServiceItems = l;
}
string GetName(ServiceDescription description)
{
if (description.Name != null) {
return description.Name;
} else if (description.RetrievalUrl != null) {
Uri uri = new Uri(description.RetrievalUrl);
if (uri.Segments.Length > 0) {
return uri.Segments[uri.Segments.Length - 1];
} else {
return uri.Host;
}
}
return String.Empty;
}
#endregion
}

17
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs

@ -55,5 +55,22 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -55,5 +55,22 @@ namespace ICSharpCode.SharpDevelop.Gui
}
return services;
}
public static string GetServiceName(ServiceDescription description)
{
if (description.Name != null) {
return description.Name;
} else if (description.RetrievalUrl != null) {
Uri uri = new Uri(description.RetrievalUrl);
if (uri.Segments.Length > 0) {
return uri.Segments[uri.Segments.Length - 1];
} else {
return uri.Host;
}
}
return String.Empty;
}
}
}

Loading…
Cancel
Save