Feature #69 Add "current XPath" shortcut
This commit is contained in:
parent
60e83ff60c
commit
5a597cd71a
|
@ -1,4 +1,5 @@
|
||||||
1.2.1.2
|
1.2.1.2
|
||||||
|
+ Feature #69 Add "current XPath" shortcut
|
||||||
+ Click on the error message to jump to the error location
|
+ Click on the error message to jump to the error location
|
||||||
* Bug #99 fix desktop file (Marco Rodrigues)
|
* Bug #99 fix desktop file (Marco Rodrigues)
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ BEGIN_EVENT_TABLE ( MyFrame, wxFrame )
|
||||||
EVT_MENU ( ID_LOCATION_PANE_VISIBLE, MyFrame::OnLocationPaneVisible )
|
EVT_MENU ( ID_LOCATION_PANE_VISIBLE, MyFrame::OnLocationPaneVisible )
|
||||||
EVT_MENU ( ID_PROTECT_TAGS, MyFrame::OnProtectTags )
|
EVT_MENU ( ID_PROTECT_TAGS, MyFrame::OnProtectTags )
|
||||||
EVT_MENU ( ID_WRAP_WORDS, MyFrame::OnWrapWords )
|
EVT_MENU ( ID_WRAP_WORDS, MyFrame::OnWrapWords )
|
||||||
|
EVT_MENU ( ID_COPY_XPATH, MyFrame::OnCopyXPath )
|
||||||
EVT_MENU_RANGE ( ID_SHOW_TAGS, ID_HIDE_TAGS, MyFrame::OnVisibilityState )
|
EVT_MENU_RANGE ( ID_SHOW_TAGS, ID_HIDE_TAGS, MyFrame::OnVisibilityState )
|
||||||
EVT_MENU_RANGE ( ID_ASSOCIATE_DTD_PUBLIC, ID_ASSOCIATE_XSL, MyFrame::OnAssociate )
|
EVT_MENU_RANGE ( ID_ASSOCIATE_DTD_PUBLIC, ID_ASSOCIATE_XSL, MyFrame::OnAssociate )
|
||||||
EVT_MENU_RANGE ( wxID_FILE1, wxID_FILE9, MyFrame::OnHistoryFile )
|
EVT_MENU_RANGE ( wxID_FILE1, wxID_FILE9, MyFrame::OnHistoryFile )
|
||||||
|
@ -201,6 +202,7 @@ BEGIN_EVENT_TABLE ( MyFrame, wxFrame )
|
||||||
EVT_UPDATE_UI ( ID_CLOSE_FIND_REPLACE_PANE, MyFrame::OnUpdateCloseFindReplacePane )
|
EVT_UPDATE_UI ( ID_CLOSE_FIND_REPLACE_PANE, MyFrame::OnUpdateCloseFindReplacePane )
|
||||||
EVT_UPDATE_UI ( ID_CLOSE_COMMAND_PANE, MyFrame::OnUpdateCloseCommandPane )
|
EVT_UPDATE_UI ( ID_CLOSE_COMMAND_PANE, MyFrame::OnUpdateCloseCommandPane )
|
||||||
EVT_UPDATE_UI ( ID_RELOAD, MyFrame::OnUpdateReload )
|
EVT_UPDATE_UI ( ID_RELOAD, MyFrame::OnUpdateReload )
|
||||||
|
EVT_UPDATE_UI ( ID_COPY_XPATH, MyFrame::OnUpdateCopyXPath )
|
||||||
EVT_IDLE ( MyFrame::OnIdle )
|
EVT_IDLE ( MyFrame::OnIdle )
|
||||||
EVT_AUINOTEBOOK_PAGE_CLOSE ( wxID_ANY, MyFrame::OnPageClosing )
|
EVT_AUINOTEBOOK_PAGE_CLOSE ( wxID_ANY, MyFrame::OnPageClosing )
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
@ -5194,6 +5196,10 @@ wxMenuBar *MyFrame::getMenuBar()
|
||||||
ID_XPATH,
|
ID_XPATH,
|
||||||
_ ( "&Evaluate XPath...\tF9" ),
|
_ ( "&Evaluate XPath...\tF9" ),
|
||||||
_ ( "Evaluate XPath..." ) );
|
_ ( "Evaluate XPath..." ) );
|
||||||
|
xmlMenu->Append (
|
||||||
|
ID_COPY_XPATH,
|
||||||
|
_ ( "Copy &The Current XPath" ),
|
||||||
|
_ ( "Copy The Current XPath" ) );
|
||||||
|
|
||||||
xmlMenu->AppendSeparator();
|
xmlMenu->AppendSeparator();
|
||||||
xmlMenu->Append (
|
xmlMenu->Append (
|
||||||
|
@ -6019,6 +6025,49 @@ void MyFrame::OnPromptGenerated ( wxNotifyEvent &event )
|
||||||
insertEntityPanel->update ( doc, wxEmptyString, wxEmptyString, true );
|
insertEntityPanel->update ( doc, wxEmptyString, wxEmptyString, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnCopyXPath ( wxCommandEvent &event )
|
||||||
|
{
|
||||||
|
XmlDoc *doc = getActiveDocument();
|
||||||
|
if ( !doc )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxBusyCursor cursor;
|
||||||
|
|
||||||
|
wxString xpath = doc->getCurrentXPath();
|
||||||
|
// Write the XPath to the clipboard
|
||||||
|
if ( xpath.IsEmpty() )
|
||||||
|
{
|
||||||
|
messagePane ( _("The current XPath is empty."), CONST_WARNING );
|
||||||
|
}
|
||||||
|
else if ( wxTheClipboard->Open() )
|
||||||
|
{
|
||||||
|
// This data objects are held by the clipboard,
|
||||||
|
// so do not delete them in the app.
|
||||||
|
wxTheClipboard->SetData ( new wxTextDataObject ( xpath ) );
|
||||||
|
wxTheClipboard->Close();
|
||||||
|
|
||||||
|
wxString message = wxString::Format
|
||||||
|
( _("The current XPath has been copied to the clipboard:[br][b]%s[/b]")
|
||||||
|
, xpath.c_str()
|
||||||
|
);
|
||||||
|
messagePane ( message, CONST_INFO );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString message = wxString::Format
|
||||||
|
( _("Failed to copy the current XPath to the clipboard:[br][b]%s[/b]")
|
||||||
|
, xpath.c_str()
|
||||||
|
);
|
||||||
|
messagePane ( message, CONST_STOP );
|
||||||
|
htmlReport->SetFocus(); // This is needed to make Ctrl + C work
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnUpdateCopyXPath ( wxUpdateUIEvent& event )
|
||||||
|
{
|
||||||
|
event.Enable ( getActiveDocument() );
|
||||||
|
}
|
||||||
|
|
||||||
wxString MyFrame::getAuxPath ( const wxString& fileName )
|
wxString MyFrame::getAuxPath ( const wxString& fileName )
|
||||||
{
|
{
|
||||||
if ( fileName.Find ( _T ( ".xsl" ) ) != wxNOT_FOUND ||
|
if ( fileName.Find ( _T ( ".xsl" ) ) != wxNOT_FOUND ||
|
||||||
|
|
|
@ -125,6 +125,7 @@ enum
|
||||||
ID_CREATE_SCHEMA,
|
ID_CREATE_SCHEMA,
|
||||||
ID_DTD_TO_SCHEMA,
|
ID_DTD_TO_SCHEMA,
|
||||||
ID_XPATH,
|
ID_XPATH,
|
||||||
|
ID_COPY_XPATH,
|
||||||
ID_XSLT,
|
ID_XSLT,
|
||||||
ID_XSLT_TEI_FO,
|
ID_XSLT_TEI_FO,
|
||||||
ID_XSLT_TEI_HTML,
|
ID_XSLT_TEI_HTML,
|
||||||
|
@ -320,6 +321,8 @@ class MyFrame : public wxFrame
|
||||||
void OnDropFiles ( wxDropFilesEvent& event );
|
void OnDropFiles ( wxDropFilesEvent& event );
|
||||||
#endif
|
#endif
|
||||||
void OnPromptGenerated ( wxNotifyEvent &event );
|
void OnPromptGenerated ( wxNotifyEvent &event );
|
||||||
|
void OnCopyXPath ( wxCommandEvent &event );
|
||||||
|
void OnUpdateCopyXPath ( wxUpdateUIEvent& event );
|
||||||
void setStrictScrolling ( bool b );
|
void setStrictScrolling ( bool b );
|
||||||
void validateRelaxNG (
|
void validateRelaxNG (
|
||||||
XmlDoc *doc,
|
XmlDoc *doc,
|
||||||
|
|
|
@ -2366,3 +2366,27 @@ void XmlCtrl::toggleComment()
|
||||||
SetSelection ( pos, pos );
|
SetSelection ( pos, pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString XmlCtrl::getCurrentXPath()
|
||||||
|
{
|
||||||
|
wxString xpath;
|
||||||
|
int pos = GetCurrentPos();
|
||||||
|
for ( ; ; )
|
||||||
|
{
|
||||||
|
pos = findPreviousStartTag ( pos, 1, '>' );
|
||||||
|
if ( pos <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
wxString name = getLastElementName ( pos );
|
||||||
|
size_t pos = name.Index ( ':' );
|
||||||
|
if ( pos != wxString::npos && pos < name.length() )
|
||||||
|
{
|
||||||
|
++pos;
|
||||||
|
name = _T("*[local-name()='")
|
||||||
|
+ name.substr ( pos, name.length() - pos ) + _T("']");
|
||||||
|
}
|
||||||
|
xpath = _T("/") + name + xpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xpath;
|
||||||
|
}
|
||||||
|
|
|
@ -160,6 +160,7 @@ class XmlCtrl: public wxStyledTextCtrl
|
||||||
void setValidationRequired ( bool b );
|
void setValidationRequired ( bool b );
|
||||||
bool selectCurrentElement();
|
bool selectCurrentElement();
|
||||||
void toggleComment();
|
void toggleComment();
|
||||||
|
wxString getCurrentXPath();
|
||||||
private:
|
private:
|
||||||
ValidationThread *validationThread; // used for background validation
|
ValidationThread *validationThread; // used for background validation
|
||||||
XmlPromptGenerator *mPromptGeneratorThread;
|
XmlPromptGenerator *mPromptGeneratorThread;
|
||||||
|
|
Loading…
Reference in New Issue