Browse Source

Made HtmlHelp2 addin use the normal search results pad.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@324 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
a7780f0bec
  1. 27
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 19
      src/AddIns/Misc/HtmlHelp2/Project/HtmlHelp2.addin
  3. 15
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs
  4. 59
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs
  5. 15
      src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs
  6. 57
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Pad/SearchResultPanel.cs
  7. 16
      src/Main/Core/Project/Src/Services/ToolBarService/ToolBarService.cs

27
AddIns/ICSharpCode.SharpDevelop.addin

@ -790,7 +790,6 @@
</Path> </Path>
<!-- end toolbars --> <!-- end toolbars -->
<Path name = "/SharpDevelop/Workbench/OpenFileTab/ContextMenu"> <Path name = "/SharpDevelop/Workbench/OpenFileTab/ContextMenu">
<MenuItem id = "Close" <MenuItem id = "Close"
label = "${res:OpenFileTabEventHandler.ContextMenu.Close}" label = "${res:OpenFileTabEventHandler.ContextMenu.Close}"
@ -1796,15 +1795,23 @@
</Path> </Path>
<Path name = "/SharpDevelop/Pads/SearchResultPanel/Toolbar"> <Path name = "/SharpDevelop/Pads/SearchResultPanel/Toolbar">
<ToolbarItem id = "ExpandAll" <Condition name = "Ownerstate" ownerstate = "DefaultMode" action = "Exclude">
icon = "Icons.16x16.OpenAssembly" <ToolbarItem id = "ExpandAll"
tooltip = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}" icon = "Icons.16x16.OpenAssembly"
class = "SearchAndReplace.ExpandAll"/> tooltip = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}"
class = "SearchAndReplace.ExpandAll"/>
<ToolbarItem id = "CollapseAll"
icon = "Icons.16x16.Assembly" <ToolbarItem id = "CollapseAll"
tooltip = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}" icon = "Icons.16x16.Assembly"
class = "SearchAndReplace.CollapseAll"/> tooltip = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}"
class = "SearchAndReplace.CollapseAll"/>
</Condition>
<Condition name = "Ownerstate" ownerstate = "SpecialPanelMode" action = "Exclude">
<ToolbarItem id = "BackToNormalView"
icon = "Icons.16x16.Assembly"
tooltip = "${res:MainWindow.Windows.SearchResultPanel.BackToNormalView.ToolTip}"
class = "SearchAndReplace.BackToNormalView"/>
</Condition>
<ToolbarItem id = "ExpandCollapseSeparator" type = "Separator" /> <ToolbarItem id = "ExpandCollapseSeparator" type = "Separator" />
<ToolbarItem id = "ShowLast" <ToolbarItem id = "ShowLast"

19
src/AddIns/Misc/HtmlHelp2/Project/HtmlHelp2.addin

@ -35,11 +35,6 @@
title = "${res:AddIns.HtmlHelp2.IndexResults}" title = "${res:AddIns.HtmlHelp2.IndexResults}"
icon = "HtmlHelp2.16x16.IndexResults" icon = "HtmlHelp2.16x16.IndexResults"
class = "HtmlHelp2.HtmlHelp2IndexResultsPad"/> class = "HtmlHelp2.HtmlHelp2IndexResultsPad"/>
<Pad id = "SearchResultsPad"
category = "Help2"
title = "${res:AddIns.HtmlHelp2.SearchResults}"
icon = "HtmlHelp2.16x16.SearchResults"
class = "HtmlHelp2.HtmlHelp2SearchResultsPad"/>
</Path> </Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> <Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
@ -73,7 +68,7 @@
shortcut = "Control|Alt|F3" shortcut = "Control|Alt|F3"
class = "HtmlHelp2.ShowSearchMenuCommand" class = "HtmlHelp2.ShowSearchMenuCommand"
insertafter = "IndexPadCommand"/> insertafter = "IndexPadCommand"/>
<MenuItem id = "FavoritesPadCommand" <!--<MenuItem id = "FavoritesPadCommand"
label = "${res:AddIns.HtmlHelp2.Favorites}" label = "${res:AddIns.HtmlHelp2.Favorites}"
icon = "HtmlHelp2.16x16.Favorites" icon = "HtmlHelp2.16x16.Favorites"
shortcut = "Control|Alt|F" shortcut = "Control|Alt|F"
@ -81,22 +76,16 @@
insertafter = "SearchPadCommand"/> insertafter = "SearchPadCommand"/>
<MenuItem id = "HtmlHelp2Separator1" <MenuItem id = "HtmlHelp2Separator1"
type = "Separator" type = "Separator"
insertafter = "FavoritesPadCommand"/> insertafter = "FavoritesPadCommand"/>-->
<MenuItem id = "IndexResultsPadCommand" <MenuItem id = "IndexResultsPadCommand"
label = "${res:AddIns.HtmlHelp2.IndexResults}" label = "${res:AddIns.HtmlHelp2.IndexResults}"
icon = "HtmlHelp2.16x16.IndexResults" icon = "HtmlHelp2.16x16.IndexResults"
shortcut = "Shift|Alt|F2" shortcut = "Shift|Alt|F2"
class = "HtmlHelp2.ShowIndexResultsMenuCommand" class = "HtmlHelp2.ShowIndexResultsMenuCommand"
insertafter = "HtmlHelp2Separator1"/> insertafter = "SearchPadCommand"/>
<MenuItem id = "SearchResultsPadCommand"
label = "${res:AddIns.HtmlHelp2.SearchResults}"
icon = "HtmlHelp2.16x16.SearchResults"
shortcut = "Shift|Alt|F3"
class = "HtmlHelp2.ShowSearchResultsMenuCommand"
insertafter = "IndexResultsPadCommand"/>
<MenuItem id = "HtmlHelp2Separator2" <MenuItem id = "HtmlHelp2Separator2"
type = "Separator" type = "Separator"
insertafter = "SearchResultsPadCommand" insertafter = "IndexResultsPadCommand"
insertbefore = "ViewGPL"/> insertbefore = "ViewGPL"/>
</Path> </Path>

15
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs

@ -237,10 +237,7 @@ namespace HtmlHelp2
return; return;
} }
PadDescriptor searchResults = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchResultsPad)); HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;
if(searchResults == null) {
return;
}
try { try {
searchIsBusy = true; searchIsBusy = true;
@ -265,8 +262,8 @@ namespace HtmlHelp2
searchDialog.Dispose(); searchDialog.Dispose();
try { try {
((HtmlHelp2SearchResultsPad)searchResults.PadContent).CleanUp(); searchResults.CleanUp();
((HtmlHelp2SearchResultsPad)searchResults.PadContent).SearchResultsListView.BeginUpdate(); searchResults.SearchResultsListView.BeginUpdate();
for(int i = 1; i <= matchingTopics.Count; i++) { for(int i = 1; i <= matchingTopics.Count; i++) {
IHxTopic topic = matchingTopics.ItemAt(i); IHxTopic topic = matchingTopics.ItemAt(i);
@ -278,15 +275,15 @@ namespace HtmlHelp2
lvi.SubItems.Add(topic.Rank.ToString()); lvi.SubItems.Add(topic.Rank.ToString());
lvi.Tag = topic; lvi.Tag = topic;
((HtmlHelp2SearchResultsPad)searchResults.PadContent).SearchResultsListView.Items.Add(lvi); searchResults.SearchResultsListView.Items.Add(lvi);
} }
} }
reuseMatches.Enabled = true; reuseMatches.Enabled = true;
} }
finally { finally {
((HtmlHelp2SearchResultsPad)searchResults.PadContent).SearchResultsListView.EndUpdate(); searchResults.SearchResultsListView.EndUpdate();
((HtmlHelp2SearchResultsPad)searchResults.PadContent).SetStatusMessage(searchTerm.Text); searchResults.SetStatusMessage(searchTerm.Text);
searchResults.BringPadToFront(); searchResults.BringPadToFront();
searchIsBusy = false; searchIsBusy = false;
} }

59
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs

@ -16,34 +16,35 @@ namespace HtmlHelp2
using MSHelpServices; using MSHelpServices;
using HtmlHelp2Service; using HtmlHelp2Service;
public class HtmlHelp2SearchResultsView : UserControl
public class ShowSearchResultsMenuCommand : AbstractMenuCommand
{
public override void Run()
{
PadDescriptor searchResults = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchResultsPad));
if(searchResults != null) searchResults.BringPadToFront();
}
}
public class HtmlHelp2SearchResultsPad : AbstractPadContent
{ {
ListView listView = new ListView(); ListView listView = new ListView();
ColumnHeader title = new ColumnHeader(); ColumnHeader title = new ColumnHeader();
ColumnHeader location = new ColumnHeader(); ColumnHeader location = new ColumnHeader();
ColumnHeader rank = new ColumnHeader(); ColumnHeader rank = new ColumnHeader();
static HtmlHelp2SearchResultsView instance;
public override Control Control public static HtmlHelp2SearchResultsView Instance {
{
get { get {
return listView; if (instance == null)
instance = new HtmlHelp2SearchResultsView();
return instance;
} }
} }
public override void RedrawContent() public void BringPadToFront()
{
PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(typeof(SearchAndReplace.SearchResultPanel));
SearchAndReplace.SearchResultPanel srp = (SearchAndReplace.SearchResultPanel)descriptor.PadContent;
srp.ShowSpecialPanel(this);
descriptor.BringPadToFront();
}
public override void Refresh()
{ {
this.SetListViewHeader(); this.SetListViewHeader();
base.Refresh();
} }
public ListView SearchResultsListView public ListView SearchResultsListView
@ -53,7 +54,7 @@ namespace HtmlHelp2
} }
} }
public HtmlHelp2SearchResultsPad() public HtmlHelp2SearchResultsView()
{ {
this.SetListViewHeader(); this.SetListViewHeader();
listView.Columns.Add(title); listView.Columns.Add(title);
@ -71,7 +72,7 @@ namespace HtmlHelp2
listView.Resize += new EventHandler(ListViewResize); listView.Resize += new EventHandler(ListViewResize);
listView.DoubleClick += new EventHandler(ListViewDoubleClick); listView.DoubleClick += new EventHandler(ListViewDoubleClick);
listView.ColumnClick += new ColumnClickEventHandler(ColumnClick); listView.ColumnClick += new ColumnClickEventHandler(ColumnClick);
listView.CreateControl(); Controls.Add(listView);
} }
private void SetListViewHeader() private void SetListViewHeader()
@ -123,14 +124,14 @@ namespace HtmlHelp2
* better if I could write what was searched and how many topics are * better if I could write what was searched and how many topics are
* matching. * matching.
*/ */
string text = StringParser.Parse("${res:AddIns.HtmlHelp2.ResultsOfSearchResults}", string text = StringParser.Parse("${res:AddIns.HtmlHelp2.ResultsOfSearchResults}",
new string[,] new string[,]
{{"0", indexTerm}, {{"0", indexTerm},
{"1", listView.Items.Count.ToString()}, {"1", listView.Items.Count.ToString()},
{"2", (listView.Items.Count == 1)?"${res:AddIns.HtmlHelp2.SingleTopic}":"${res:AddIns.HtmlHelp2.MultiTopic}"}} {"2", (listView.Items.Count == 1)?"${res:AddIns.HtmlHelp2.SingleTopic}":"${res:AddIns.HtmlHelp2.MultiTopic}"}}
); );
StatusBarService.SetMessage(text); StatusBarService.SetMessage(text);
} }
#region Sorting #region Sorting
@ -148,8 +149,8 @@ namespace HtmlHelp2
int a = Int32.Parse(((ListViewItem)x).SubItems[col].Text); int a = Int32.Parse(((ListViewItem)x).SubItems[col].Text);
int b = Int32.Parse(((ListViewItem)y).SubItems[col].Text); int b = Int32.Parse(((ListViewItem)y).SubItems[col].Text);
if(a > b) return 1; if(a > b) return 1;
else if(a < b) return -1; else if(a < b) return -1;
else return 0; else return 0;
default: default:
return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text); return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
} }

15
src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
public override Control Control { public override Control Control {
get { get {
return contentPanel; return contentPanel;
@ -123,7 +123,7 @@ namespace ICSharpCode.SharpDevelop.Gui
listView.Resize += new EventHandler(ListViewResize); listView.Resize += new EventHandler(ListViewResize);
listView.CreateControl(); listView.CreateControl();
contentPanel.Controls.Add(listView); contentPanel.Controls.Add(listView);
toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/ErrorList/Toolbar"); toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/ErrorList/Toolbar");
toolStrip.Stretch = true; toolStrip.Stretch = true;
toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
@ -188,7 +188,7 @@ namespace ICSharpCode.SharpDevelop.Gui
taskToolTip.SetToolTip(listView, description); taskToolTip.SetToolTip(listView, description);
taskToolTip.Active = true; taskToolTip.Active = true;
} else { } else {
taskToolTip.RemoveAll(); taskToolTip.RemoveAll();
taskToolTip.Active = false; taskToolTip.Active = false;
} }
currentListViewItem = item; currentListViewItem = item;
@ -291,7 +291,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// <summary> /// <summary>
/// Removes new lines, carriage returns and tab characters from /// Removes new lines, carriage returns and tab characters from
/// the list view task description and replaces them with a space. /// the list view task description and replaces them with a space.
/// </summary> /// </summary>
/// <param name="description">The task list description.</param> /// <param name="description">The task list description.</param>
/// <returns>A formatted task list description.</returns> /// <returns>A formatted task list description.</returns>
@ -304,11 +304,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void UpdateToolstripStatus() void UpdateToolstripStatus()
{ {
foreach (ToolStripItem item in toolStrip.Items) { ToolbarService.UpdateToolbar(toolStrip);
if (item is IStatusUpdate) {
((IStatusUpdate)item).UpdateStatus();
}
}
} }
void InternalShowResults() void InternalShowResults()
@ -327,7 +323,6 @@ namespace ICSharpCode.SharpDevelop.Gui
listView.EndUpdate(); listView.EndUpdate();
UpdateToolstripStatus(); UpdateToolstripStatus();
} }
} }
} }

57
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Pad/SearchResultPanel.cs

@ -22,13 +22,14 @@ using ICSharpCode.SharpDevelop.Gui;
namespace SearchAndReplace namespace SearchAndReplace
{ {
public enum SearchResultPanelViewMode { public enum SearchResultPanelViewMode
Flat, {
Flat,
PerFile, PerFile,
Structural Structural
} }
public class SearchResultPanel : AbstractPadContent public class SearchResultPanel : AbstractPadContent, IOwnerState
{ {
static SearchResultPanel instance; static SearchResultPanel instance;
@ -38,8 +39,9 @@ namespace SearchAndReplace
} }
} }
Panel myPanel = new Panel(); Panel myPanel = new Panel();
ExtTreeView resultTreeView = new ExtTreeView(); ExtTreeView resultTreeView = new ExtTreeView();
ToolStrip toolStrip;
string curPattern = null; string curPattern = null;
List<SearchResult> curResults = null; List<SearchResult> curResults = null;
@ -139,6 +141,8 @@ namespace SearchAndReplace
public void ShowSearchResults(string pattern, List<SearchResult> results) public void ShowSearchResults(string pattern, List<SearchResult> results)
{ {
RemoveSpecialPanel();
this.curPattern = pattern; this.curPattern = pattern;
this.curResults = results; this.curResults = results;
if (results == null) { if (results == null) {
@ -167,12 +171,53 @@ namespace SearchAndReplace
resultTreeView.Dock = DockStyle.Fill; resultTreeView.Dock = DockStyle.Fill;
resultTreeView.Font = ExtTreeNode.Font; resultTreeView.Font = ExtTreeNode.Font;
resultTreeView.IsSorted = false; resultTreeView.IsSorted = false;
ToolStrip toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/SearchResultPanel/Toolbar"); toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/SearchResultPanel/Toolbar");
toolStrip.Stretch = true; toolStrip.Stretch = true;
toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
myPanel.Controls.AddRange(new Control[] { resultTreeView, toolStrip} ); myPanel.Controls.AddRange(new Control[] { resultTreeView, toolStrip} );
} }
// Special panel mode:
enum SearchResultPanelOwnerState
{
DefaultMode = 1,
SpecialPanelMode = 2,
// warning: OwnerState does a FLAG comparison!
}
Control specialPanel;
Enum IOwnerState.InternalState {
get {
return (specialPanel != null) ? SearchResultPanelOwnerState.SpecialPanelMode : SearchResultPanelOwnerState.DefaultMode;
}
}
public void ShowSpecialPanel(Control ctl)
{
ctl.Dock = DockStyle.Fill;
if (specialPanel == ctl)
return;
if (specialPanel != null)
myPanel.Controls.Remove(specialPanel);
else
myPanel.Controls.Remove(resultTreeView);
specialPanel = ctl;
myPanel.Controls.Add(ctl);
myPanel.Controls.SetChildIndex(ctl, 0);
ToolbarService.UpdateToolbar(toolStrip);
}
public void RemoveSpecialPanel()
{
if (specialPanel != null) {
specialPanel = null;
myPanel.Controls.Remove(specialPanel);
myPanel.Controls.Add(resultTreeView);
myPanel.Controls.SetChildIndex(resultTreeView, 0);
ToolbarService.UpdateToolbar(toolStrip);
}
}
} }
} }

16
src/Main/Core/Project/Src/Services/ToolBarService/ToolBarService.cs

@ -11,7 +11,7 @@ using System.Windows.Forms;
namespace ICSharpCode.Core namespace ICSharpCode.Core
{ {
public static class ToolbarService public static class ToolbarService
{ {
// readonly static string toolBarPath = "/SharpDevelop/Workbench/ToolBar"; // readonly static string toolBarPath = "/SharpDevelop/Workbench/ToolBar";
@ -35,14 +35,15 @@ namespace ICSharpCode.Core
{ {
ToolStrip toolStrip = new ToolStrip(); ToolStrip toolStrip = new ToolStrip();
toolStrip.Items.AddRange(CreateToolStripItems(owner, treeNode)); toolStrip.Items.AddRange(CreateToolStripItems(owner, treeNode));
UpdateToolbar(toolStrip); // setting Visible is only possible after the items have been added
return toolStrip; return toolStrip;
} }
public static ToolStrip CreateToolStrip(object owner, string addInTreePath) public static ToolStrip CreateToolStrip(object owner, string addInTreePath)
{ {
ToolStrip toolStrip = new ToolStrip(); ToolStrip toolStrip = new ToolStrip();
toolStrip.ShowItemToolTips = true;
toolStrip.Items.AddRange(CreateToolStripItems(owner, addInTreePath)); toolStrip.Items.AddRange(CreateToolStripItems(owner, addInTreePath));
UpdateToolbar(toolStrip); // setting Visible is only possible after the items have been added
return toolStrip; return toolStrip;
} }
@ -53,7 +54,7 @@ namespace ICSharpCode.Core
treeNode = AddInTree.GetTreeNode(addInTreePath); treeNode = AddInTree.GetTreeNode(addInTreePath);
} catch (TreePathNotFoundException) { } catch (TreePathNotFoundException) {
return null; return null;
} }
List<ToolStrip> toolBars = new List<ToolStrip>(); List<ToolStrip> toolBars = new List<ToolStrip>();
foreach (AddInTreeNode childNode in treeNode.ChildNodes.Values) { foreach (AddInTreeNode childNode in treeNode.ChildNodes.Values) {
@ -61,5 +62,14 @@ namespace ICSharpCode.Core
} }
return toolBars.ToArray(); return toolBars.ToArray();
} }
public static void UpdateToolbar(ToolStrip toolStrip)
{
foreach (ToolStripItem item in toolStrip.Items) {
if (item is IStatusUpdate) {
((IStatusUpdate)item).UpdateStatus();
}
}
}
} }
} }

Loading…
Cancel
Save