Browse Source

Rearrange Messages, cleanup

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

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

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

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

@ -38,13 +38,33 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
string header1 = "To see a list of available services on an specific Server, "; 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 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 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; 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) public AddServiceReferenceViewModel(IProject project)
{ {
Project = project; project = project;
title = "Add Service Reference";
discoverButtonContend = "Disvover"; discoverButtonContend = "Disvover";
HeadLine = header1 + header2; HeadLine = header1 + header2;
@ -56,70 +76,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
TwoValues = new ObservableCollection<TwoValue>(); 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 #region Go
@ -134,6 +90,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
StartDiscovery(uri, new DiscoveryNetworkCredential(CredentialCache.DefaultNetworkCredentials, DiscoveryNetworkCredential.DefaultAuthenticationType)); StartDiscovery(uri, new DiscoveryNetworkCredential(CredentialCache.DefaultNetworkCredentials, DiscoveryNetworkCredential.DefaultAuthenticationType));
} }
private bool CanExecuteGo() private bool CanExecuteGo()
{ {
return true; return true;
@ -142,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
#endregion #endregion
#region Discover #region Discover Command
public System.Windows.Input.ICommand DiscoverCommand {get;private set;} public System.Windows.Input.ICommand DiscoverCommand {get;private set;}
@ -160,18 +117,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
#region discover service Code from Matt #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) void StartDiscovery(Uri uri, DiscoveryNetworkCredential credential)
{ {
// Abort previous discovery. // Abort previous discovery.
@ -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); NetworkCredential matchedCredential = credentialCache.GetCredential(uri, credential.AuthenticationType);
if (matchedCredential != null) { if (matchedCredential != null) {
@ -275,22 +221,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
void DiscoveredWebServices(DiscoveryClientProtocol protocol) void DiscoveredWebServices(DiscoveryClientProtocol protocol)
{ {
if (protocol != null) { if (protocol != null) {
// webServicesView.Add(GetServiceDescriptions(protocol)); serviceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol);
ServiceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol); ServiceDescriptionMessage = String.Format("{0} service(s) found at address {1}",
FillItems (ServiceDescriptionCollection); serviceDescriptionCollection.Count,
var defaultNameSpace = GetDefaultNamespace(); discoveryUri);
DefaultNameSpace = GetDefaultNamespace();
FillItems (serviceDescriptionCollection);
var referenceName = GetReferenceName(discoveryUri); var referenceName = GetReferenceName(discoveryUri);
/*
webReference = new ICSharpCode.SharpDevelop.Gui.WebReference(project,
discoveryUri.AbsoluteUri,
defaultNameSpace,
referenceName, protocol);
*/
}
else
{
// webReference = null;
} }
} }
@ -315,37 +253,49 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
return uri.Host; return uri.Host;
} }
return String.Empty; 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 { get {return title;}
return serviceDescriptionCollection; set {title = value;
} base.RaisePropertyChanged(() =>Title);
set
{
serviceDescriptionCollection = value;
RaisePropertyChanged(() =>ServiceDescriptionCollection);
} }
} }
#endregion public string HeadLine {get; set;}
private string discoverButtonContend;
#region new binding public string DiscoverButtonContend {
get { return discoverButtonContend; }
set { discoverButtonContend = value;
base.RaisePropertyChanged(() =>DiscoverButtonContend);}
}
List<ServiceItem> items = new List <ServiceItem>();
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 { public List <ServiceItem> ServiceItems {
get {return items; } get {return items; }
@ -356,8 +306,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
} }
ServiceItem myItem;
public ServiceItem ServiceItem { public ServiceItem ServiceItem {
get { return myItem; } get { return myItem; }
set { myItem = value; set { myItem = value;
@ -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 { public ObservableCollection<TwoValue> TwoValues {
get { return twoValues; } get { return twoValues; }
@ -378,7 +339,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
} }
public void UpdateListView () void UpdateListView ()
{ {
TwoValues.Clear(); TwoValues.Clear();
string l; string l;
@ -440,14 +401,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
{ {
Add (element); Add (element);
} }
} }
void Add(ServiceDescription description) void Add(ServiceDescription description)
{ {
List<ServiceItem> l = new List<ServiceItem>(); 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; rootNode.Tag = description;
l.Add(rootNode); l.Add(rootNode);
@ -479,25 +440,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog
} }
ServiceItems = l; 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 #endregion
} }

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

@ -55,5 +55,22 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
return services; 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