Skip to content

Commit

Permalink
* FIX: several focus-related issues with ribbon-buttons
Browse files Browse the repository at this point in the history
* FIX: Generate XPath for attributes
* FIX: workaround: couldn't detect wellformedness of UTF8-BOM encoded XML (can be disabled in options)
* NEW: Minor improvements in search with Ctrl+F
* NEW: Search'n'Replace can handle plain text
* NEW: Copy XPath of node in XmlGridView to clipboard
* NEW: Copy value of node in XmlGridView to clipboard
  • Loading branch information
fschnitz committed Apr 14, 2015
1 parent af2ddd3 commit c1f716c
Show file tree
Hide file tree
Showing 29 changed files with 319 additions and 85 deletions.
12 changes: 8 additions & 4 deletions TODOs.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
!! Done in current release

* FIX: Issue #4: Encoding of some xml files gets detected wrong
* NEW:
* FIX: several focus-related issues with ribbon-buttons
* FIX: Generate XPath for attributes
* FIX: workaround: couldn't detect wellformedness of UTF8-BOM encoded XML (can be disabled in options)
* NEW: Minor improvements in search with Ctrl+F
* NEW: Search'n'Replace can handle plain text
* NEW: Copy XPath of node in XmlGridView to clipboard
* NEW: Copy value of node in XmlGridView to clipboard
* CHG:



= TODOs =

* plain-text Suchen und Ersetzen
* Code Completion tut nicht für Typen mit restriction-base, wenn Basis Attribute definiert
* XSD-mode: per Shortcut xsd:annotation einfügen
* Screenshots auf Homepage aktualisieren
Expand All @@ -35,7 +39,7 @@
* GridView is read-only

== low prio ==
* GridView: Zelle markieren und 'copy XPath', insert element, delete element, comment out, rename (aus Forum)
* GridView erweitern: Position synchron halten, auch nach Wechsel zum Editor und zurück; Zelle markieren und insert element, delete element, comment out, rename (aus Forum)
* TCP Listener: Auto-Scrolldown
* Öffnender und schließender Tag synchron halten (vgl. VS)
* Highlighting fuer beliebige Dateien ausschalten
Expand Down
11 changes: 7 additions & 4 deletions Xsemmel/AboutBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<Paragraph>
Html Agility Pack
<LineBreak/>
Ms-PL
Version 1.4.9, Ms-PL
<LineBreak/>
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="http://htmlagilitypack.codeplex.com">http://htmlagilitypack.codeplex.com</Hyperlink>
</Paragraph>
Expand All @@ -75,9 +75,9 @@
<Paragraph>
Property Tools
<LineBreak/>
Ms-PL
Version 2015.1.56, MIT
<LineBreak/>
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="http://propertytools.codeplex.com">http://propertytools.codeplex.com</Hyperlink>
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/objorke/PropertyTools">https://github.com/objorke/PropertyTools</Hyperlink>
</Paragraph>
</ListItem>
<ListItem>
Expand Down Expand Up @@ -108,12 +108,15 @@
<FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
Copyright (c) 2007-2014, Frank Schnitzer
Copyright (c) 2007-2015, Frank Schnitzer
<LineBreak/>
<LineBreak/>
All rights reserved.
<LineBreak/>
<LineBreak/>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
<LineBreak/>
<LineBreak/>
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Expand Down
2 changes: 1 addition & 1 deletion Xsemmel/ApplicationMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ApplicationMenu()

private void btnOptions_Click(object sender, RoutedEventArgs e)
{
new ConfigurationWnd {Owner = Application.Current.MainWindow}.ShowDialog();
new ConfigurationWnd {Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner}.ShowDialog();
}

private void ApplicationMenu_OnIsOpenChanged(object sender, DependencyPropertyChangedEventArgs e)
Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/CopyFilenameCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
if (ef.XSDocument == null)
{
return false;
Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/Dec2HexCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
if (ef.XmlEditor.SelectionLength == 0)
{
return false;
Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/EscapeBase64StringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/EscapeXmlStringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/ExportAsHtmlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
if (ef.XSDocument == null)
{
return false;
Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/Hex2DecCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
if (ef.XmlEditor.SelectionLength == 0)
{
return false;
Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/InsertCurrentDateTimeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/UnescapeBase64StringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/UnescapeCsStringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions Xsemmel/Commands/UnescapeXmlStringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ protected override bool CanExecute(EditorFrame ef)
{
return false;
}
if (!ef.XmlEditor.TextArea.IsFocused)
{
return false;
}
// if (!ef.XmlEditor.TextArea.IsFocused)
// {
// return false;
// }
return true;
}

Expand Down
22 changes: 20 additions & 2 deletions Xsemmel/Configuration/ConfigObj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class XsdMapItem : INotifyPropertyChanged
{
public string Name { get; set; }
public string Mapping { get; set; }

public event PropertyChangedEventHandler PropertyChanged;
}

Expand All @@ -34,21 +35,32 @@ public class XsdMapItem : INotifyPropertyChanged
private bool _watchCurrentFileForChanges = true;
private bool _alwaysPrettyprintFragments = true;
private bool _enableCodeCompletion = true;
private bool _workaroundUtf8BomBug = true;
private const int MAX_RECENTLY_USED_FILES = 5;
private readonly List<string> _recentlyUsedFiles = new List<string>(); //cannot use LinkedList due to serialization
private List<XsdMapItem> _xsdMapping = new List<XsdMapItem>();



[Category("General|Application")]
public bool ShowSplashScreen
{
get { return _showSplashScreen; }
set { _showSplashScreen = value; }
}

[Category("General|Application")]
[DisplayName("Replace \"?> by \" ?> as workaround for UTF8-BOM files: ")]
public bool WorkaroundUtf8BomBug
{
get { return _workaroundUtf8BomBug; }
set { _workaroundUtf8BomBug = value; }
}

[Category("Schema|XSD mapping")]
[Column(0, "Name", "Replace", null, "2*", 'L')]
[Column(1, "Mapping", "by", null, "1*", 'L')]
// [DisplayName(" ")]
// [Column(0, "Name", "Replace", null, "1*", 'L')] //TODO bug in PropertyTools prevents to show this columnname correctly
// [Column(1, "Mapping", "by", null, "2*", 'R')]
[HeaderPlacement(HeaderPlacement.Collapsed)]
public List<XsdMapItem> XsdMapping
{
Expand All @@ -58,8 +70,10 @@ public List<XsdMapItem> XsdMapping


[Category("Schema|XSD mapping")]
[DisplayName(" ")]
[Comment]
[XmlIgnore]
[HeaderPlacement(HeaderPlacement.Collapsed)]
public string Comment
{
get { return "All xsd's with the specified name will be replaced by the path of the mapping"; }
Expand Down Expand Up @@ -118,7 +132,9 @@ public string LastOpenedFile

[Category("External Tools|")]
[Comment]
// [DisplayName(" ")]
[XmlIgnore]
[HeaderPlacement(HeaderPlacement.Collapsed)]
public string Comment3
{
get { return "You can specifiy up to three external tools. Please specify command lines to run the tools:"; }
Expand Down Expand Up @@ -151,6 +167,8 @@ public string Comment3

[Category("External Tools|")]
[Comment]
// [DisplayName(" ")]
[HeaderPlacement(HeaderPlacement.Collapsed)]
[XmlIgnore]
public string Comment2
{
Expand Down
1 change: 1 addition & 0 deletions Xsemmel/Editor/FindString.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public void StartSearch()
{
Keyboard.Focus(_edtSearchText);
bool success = _edtSearchText.Focus();
_edtSearchText.SelectAll();
Debug.Assert(success);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Xsemmel/Editor/XmlGridView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Foreground="DarkRed" Background="Transparent" Visibility="Collapsed">
Errors
</Label>
<WindowsFormsHost>
<WindowsFormsHost x:Name="_winformsHost" x:FieldModifier="private">
<GridView:XmlGridView x:Name="_xmlGridView" x:FieldModifier="private" AutoHeightCells="True"/>
</WindowsFormsHost>
</DockPanel>
Expand Down
48 changes: 47 additions & 1 deletion Xsemmel/Editor/XmlGridView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,77 @@
using System;
using System.Drawing;
using System.Windows;
using System.Xml;
using WmHelp.XmlGrid;
using XSemmel.Helpers;
using ContextMenu = System.Windows.Forms.ContextMenu;
using MenuItem = System.Windows.Forms.MenuItem;


namespace XSemmel.Editor
{

public partial class XmlGridView
{
private EditorFrame _editor;
private System.Drawing.Point _contextMenuAtPos;

public XmlGridView()
{
InitializeComponent();
_xmlGridView.MouseDown += (sender, args) => { _contextMenuAtPos = args.Location; };

_xmlGridView.ContextMenu = new ContextMenu(
new[]
{
new MenuItem("Refresh", (sender, evt) => load()),
new MenuItem("Expand all", (sender, evt) => _xmlGridView.FullExpand()),
new MenuItem("-"),
new MenuItem("Copy", (sender, evt) =>
{
Rectangle rect = new Rectangle();
GridCell cell = _xmlGridView.FindCellByPoint(_contextMenuAtPos, ref rect);
cell.CopyToClipboard();
}),
new MenuItem("Copy XPath", (sender, evt) =>
{
Rectangle rect = new Rectangle();
GridCell cell = _xmlGridView.FindCellByPoint(_contextMenuAtPos, ref rect);

XmlNode node;
if (cell is XmlLabelCell)
{
node = ((XmlLabelCell) cell).Node;
}
else if (cell is XmlValueCell)
{
node = ((XmlValueCell)cell).Node;
}
else if (cell is XmlDeclarationCell)
{
node = ((XmlDeclarationCell)cell).Node;
}
else if (cell is XmlGroupCell)
{
node = ((XmlGroupCell)cell).Node;
}
else
{
MessageBox.Show("Selected cell is not a XML node. Can't copy XPath", "Error",
MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

if (node != null)
{
var xpath = XPathBuilder.GetXPathToNode(node);
Clipboard.SetText(xpath);
}
}),
});
}


private void load()
{
try
Expand Down
Loading

0 comments on commit c1f716c

Please sign in to comment.