Browse Source

recent changes to ToolBarDropDownButton are now compatible with previous usage, notably in the SearchAndReplace toolbar.

AddIn schema now updated to reflect recent addition to ToolbarItemDoozer; new ToolbarItem types are now available via code-completion in AddIn.xsd

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1338 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Alpert 20 years ago
parent
commit
32abd834aa
  1. 17
      data/schemas/AddIn.xsd
  2. 18
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/Gui/ToolBarDropDownButton.cs

17
data/schemas/AddIn.xsd

@ -616,7 +616,7 @@
<xs:annotation> <xs:annotation>
<xs:documentation> <xs:documentation>
This attribute must be one of these values: This attribute must be one of these values:
Separator, CheckBox, Item=Command, Menu (=with subitems), Separator, CheckBox, Item (=Command), Menu (=with subitems),
Builder (=class implementing ISubmenuBuilder). Builder (=class implementing ISubmenuBuilder).
Default: Command. Default: Command.
</xs:documentation> </xs:documentation>
@ -864,13 +864,19 @@
<xs:enumeration value="CheckBox" /> <xs:enumeration value="CheckBox" />
<xs:enumeration value="Item" /> <xs:enumeration value="Item" />
<xs:enumeration value="ComboBox" /> <xs:enumeration value="ComboBox" />
<xs:enumeration value="TextBox" />
<xs:enumeration value="Label" />
<xs:enumeration value="DropDownButton" /> <xs:enumeration value="DropDownButton" />
<xs:enumeration value="SplitButton" />
<xs:enumeration value="Builder" />
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:annotation> <xs:annotation>
<xs:documentation> <xs:documentation>
This attribute must be one of these values: This attribute must be one of these values:
Separator, CheckBox, Item, ComboBox, DropDownButton Separator, CheckBox, Item, ComboBox, DropDownButton,
ComboBox, TextBox, Label, DropDownButton,
SplitButton (=Command with MenuItem subitems)
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:attribute> </xs:attribute>
@ -879,6 +885,13 @@
<xs:documentation> <xs:documentation>
Only for the type "Item". When set to false, the command class is loaded Only for the type "Item". When set to false, the command class is loaded
immediately instead of the usual lazy-loading. immediately instead of the usual lazy-loading.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="label" use="optional" type="xs:string">
<xs:annotation>
<xs:documentation>
Label of the tool bar item.
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:attribute> </xs:attribute>

18
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/Gui/ToolBarDropDownButton.cs

@ -15,6 +15,7 @@ namespace ICSharpCode.Core
{ {
object caller; object caller;
Codon codon; Codon codon;
ICommand menuBuilder = null;
ArrayList subItems; ArrayList subItems;
public ToolBarDropDownButton(Codon codon, object caller, ArrayList subItems) public ToolBarDropDownButton(Codon codon, object caller, ArrayList subItems)
@ -30,6 +31,10 @@ namespace ICSharpCode.Core
if (Image == null && codon.Properties.Contains("icon")) { if (Image == null && codon.Properties.Contains("icon")) {
Image = ResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"])); Image = ResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
} }
if (menuBuilder == null && codon.Properties.Contains("class")) {
menuBuilder = codon.AddIn.CreateObject(StringParser.Parse(codon.Properties["class"])) as ICommand;
menuBuilder.Owner = this;
}
UpdateStatus(); UpdateStatus();
UpdateText(); UpdateText();
@ -37,6 +42,19 @@ namespace ICSharpCode.Core
void CreateDropDownItems() void CreateDropDownItems()
{ {
// let's assume that if a menuBuilder exists,
// as in the Search Results panel or the Class
// Browser toolbar, it will handle this step.
if (menuBuilder != null) {
return;
}
// also, let's prevent a null exception
// in the event that there are no subitems
if (subItems == null || subItems.Count==0) {
return;
}
DropDownItems.Clear(); DropDownItems.Clear();
foreach (object item in subItems) foreach (object item in subItems)
{ {

Loading…
Cancel
Save