Add submenu in menupopup mozilla extension developmet? - firefox

Here I am working with firefox extension development. I have using XUL Overlays to add menu popup item in my extension.
<menupopup id="menu_ToolsPopup">
<menuitem label="HP Scheduler Options..."
insertafter="devToolsSeparator"
oncommand="openPreferences('hpschedPane');" />
</menupopup>
Here I need to add sub menu with menu item.

<menupopup id="menu_ToolsPopup">
<menuitem label="HP Scheduler Options..."
insertafter="devToolsSeparator"
oncommand="openPreferences('hpschedPane');" />
<menu id="..." label="My submenu!">
<menupopup>
<menuitem label="My menu item in the submenu!" oncommand="..." />
</menupopup>
</menu>
</menupopup>

Related

VSIX/VSPackage: Solution Control Explorer context menu

I am having a lot of issues trying to understand how to get a submenu working in VisualStudio 2013's Solution Control Explorer, when creating a VSPackage project. I am able to add buttons, and that is great. However, I want to create the submenus such as the existing "Find" and "Advanced":
The code below is getting the two buttons in the menu list (as seen in the image/link above), but it does not show the submenu. I have tried to add buttons to the submenu, but it still does not show.
<Commands package="guidFirstPackagePkg">
<Menus>
<Menu guid="guidVSPackage3CmdSet" id="SubMenu" priority="0x0100" type="Menu">
<Parent guid="guidSourceControlExplorerMenuGroup" id="SourceControlExplorerMenuGroupId"/>
<Strings>
<ButtonText>Sub Menu</ButtonText>
<CommandName>Sub Menu</CommandName>
</Strings>
</Menu>
</Menus>
<!--Buttons section. -->
<Buttons>
<Button guid="guidVSPackage2CmdSet" id="cmdIdImport" priority="0x0100" type="Button">
<Parent guid="guidSourceControlExplorerMenuGroup" id="SourceControlExplorerMenuGroupId" />
<Strings>
<ButtonText>Import</ButtonText>
</Strings>
</Button>
<Button guid="guidVSPackage2CmdSet" id="cmdIdExport" priority="0x0100" type="Button">
<Parent guid="guidSourceControlExplorerMenuGroup" id="SourceControlExplorerMenuGroupId" />
<Strings>
<ButtonText>Export</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
<Symbols>
<!-- This is the package guid. -->
<GuidSymbol name="guidFirstPackagePkg" value="{fd27b3da-39c0-486a-9900-652cb81b0744}" />
<GuidSymbol name="guidSourceControlExplorerMenuGroup" value="{ffe1131c-8ea1-4d05-9728-34ad4611bda9}">
<IDSymbol name="SourceControlExplorerMenuGroupId" value="0x1111" />
</GuidSymbol>
<GuidSymbol name="guidVSPackage2CmdSet" value="{1d975044-0a78-4e91-a6c2-2e841f4280e4}">
<IDSymbol name="cmdIdImport" value="0x0100" />
<IDSymbol name="cmdIdExport" value="0x0110" />
</GuidSymbol>
<GuidSymbol name="guidVSPackage3CmdSet" value="{C860DEF0-0A00-44BE-A8D9-393BACE1A44A}">
<IDSymbol name="SubMenu" value="0x1001"/>
</GuidSymbol>
</Symbols>
Any ideas of what I am doing wrong? Wrong linking, can I not use the same "SourceControlExplorerMenuGroupId" for menus, but only buttons?
I know a related post dealt with the addition of a button to the Solution Control Explorer, however, I was unable to replicated this for a Solution Control Explorer submenu:
Creating VSIX package for TFS Source control explorer context menu extension
Another reference I tried, but was not related to Solution Control Explorer:
Why isn't my vspackage's context menu showing
Your <Menus> code is fine.
Create a group with its parent guid and id matching your menu guid and id:
<Groups>
<Group guid="guidVSPackage3CmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidVSPackage3CmdSet" id="SubMenu" />
</Group>
</Groups>
Then, just have your buttons be children of the group:
<Buttons>
<Button guid="guidVSPackage2CmdSet" id="cmdIdImport" priority="0x0100" type="Button">
<Parent guid="guidVSPackage3CmdSet" id="MyMenuGroup" />
<Strings>
<ButtonText>Import</ButtonText>
</Strings>
</Button>
<Button guid="guidVSPackage2CmdSet" id="cmdIdExport" priority="0x0100" type="Button">
<Parent guid="guidVSPackage3CmdSet" id="MyMenuGroup" />
<Strings>
<ButtonText>Export</ButtonText>
</Strings>
</Button>
</Buttons>

Adding a button to account entity homepage's ribbon/command bar

Playing with the ribbon, I tried to add a button over the account entity homepage's ribbon/command bar, just before the +New button. But it is not showing anywhere over the page. What am I missing?
This is the sample XML I've coded after reading the SDK.
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children">
<CommandUIDefinition>
<Button Id="Bee.HomepageGrid.account.GoToUrl" Command="Bee.CommandDefinition.GoToUrl" LabelText="Go To URL" ToolTipDescription="Description, Go to URL with selected account" ToolTipTitle="Title, Go to URL with selected account" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients"/>
</DisplayRules>
<Actions>
<Url Address="http://localhost/mysite" PassParams="true"></Url>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Modern" />
<CommandClientTypeRule Type="Refresh" />
<CommandClientTypeRule Type="Legacy" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne">
<SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
I just apply one CommandClientTypeRule Type="Refresh", it works. Again apply all three types not working. All have different meanings as below.
Modern: The command bar is presented using Microsoft Dynamics CRM for tablets.
Refresh: The command bar is presented using the updated user interface.
Legacy: The ribbon is presented in forms for entities that were not updated or in a list view in Microsoft Dynamics CRM for Microsoft Office Outlook.
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Refresh" />
</DisplayRule>
</DisplayRules>
But Go to url button goes to overflow section means in the drop down hidden menu.
Displaying the button on command bar before NEW button apply some sequence, following is RibbonXml that show the button just before NEW button, when one record is selected.
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children" Sequence="5">
<CommandUIDefinition>
<Button Id="Bee.HomepageGrid.account.GoToUrl"
LabelText="Go To URL"
ToolTipDescription="Description, Go to URL with selected account"
ToolTipTitle="Title, Go to URL with selected account"
Alt="Go to"
Command="Bee.CommandDefinition.GoToUrl"
Sequence="5"
TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients"/>
</DisplayRules>
<Actions>
<Url Address="http://localhost/mysite" PassParams="true"></Url>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Refresh" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne">
<SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels/>
</RibbonDiffXml>
I would suggest you to try Ribbon Workbench. You don't need to download/extract/modify/pack/import anymore. Everything is done directly from Dynamics CRM and without any knowledge of XML.
You should add LocLabels to your RibbonDiffXml. Attribute LabelText a.o. must hold references to these localized labels. They are not meant to hold the texts themselves.
Look on CodePlex for some fine ribbon editors; they will give you a good start!

ff addon execute menu item

I want to modify an existing addon for simplicity. I have this code:
<popup id="contentAreaContextMenu">
<menu id="llOpenLocalLink" label="&llOpenLocalLink.label;" insertbefore="context-sep-open" >
<menupopup>
<menuitem id="llOpenInThisTab" label="&llOpenInThisTab.label;" oncommand="LocalLink.openLinkInThisTab(event)"/>
<menuitem id="llOpenInNewTab" label="&llOpenInNewTab.label;" oncommand="LocalLink.openLinkInNewTab(event)"/>
<menuitem id="llOpenInNewWindow" label="&llOpenInNewWindow.label;" oncommand="LocalLink.openLinkInNewWindow(event)"/>
</menupopup>
</menu>
</popup>
And I only want a single menu entry which is executed if clicked. I tried this but it is not executed:
<popup id="contentAreaContextMenu">
<menu id="llOpenLocalLink" label="&llOpenLocalLink.label;" insertbefore="context- sep-open" oncommand="LocalLink.openLinkInNewTab(event)">
</menu>
</popup>
Ok. I found the answer:
<popup id="contentAreaContextMenu">
<menuitem id="llOpenLocalLink" label="&llOpenLocalLink.label;" insertbefore="context-sep-open" oncommand="LocalLink.openLinkInNewTab(event)"/>
</popup>

Firefox Extension - How to use preference for a menulist?

I'm trying to use the tag <preference> for saving the state of a <menulist>. But I can't find out of what i'm doing wrong.
Here's my code:
<preferences>
<preference id="selectpref1" name="preference.name" type="int" />
</preferences>
<menulist>
<menupopup preference="selectpref1">
<menuitem label="option 1" value="1"/>
<menuitem label="option 2" value="2"/>
<menuitem label="option 3" value="3"/>
<menuitem label="option 4" value="4"/>
</menupopup>
</menulist>
You can do it, here's code from my extension:
<hbox align="center">
<label value="Log Level" control="loglevellist" />
<menulist id="loglevellist" preference="loglevel" preference-editable="true">
<menupopup>
<menuitem label="Full" value="0" />
<menuitem label="Relevant" value ="1" />
<menuitem label="Warning" value="2" />
<menuitem label="Error" value="3" />
<menuitem label="Critical" value="4" />
</menupopup>
</menulist>
</hbox>
loglevel preference is integer. Basically I think you're only missing preference-editable attribute
EDIT:
I didn't see properly, you had preference attribute on menupopup instead on menulist - preference should go on menulist.
I'm pretty sure you can't do that. You just need to add an oncommand to each of the menuitems, which changes the preference. You might also want to add a listener for the "popupshowing" event, which checks the preference and puts a checkmark by whichever one is currently selected.
See https://developer.mozilla.org/en/Code_snippets/Preferences

How to insert image in status bar?

I want to create an image in my statusbar, but why it can't appear?
And, how to add menu in status bar when I click right the mouse?
This is my script:
<?xml version="1.0"?>
<!--
# Fungsi dari file ini adalah mengatur tampilan dan perilaku addon.
# Membuat menu "search hadits" pada saat user klik kanan pada halaman browser atau
# pada saat user klik kanan pada kata di halaman browser.
-->
<overlay id="inline_trans"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--
# Membuat Menu Klik kanan pada halaman firefox.
# Memanggil fungsi pada haditsSearch.js untuk mulai melakukan pencarian hadits.
-->
<popup id="contentAreaContextMenu">
<menuitem class="inlinetrans" id="inlineContext" oncommand= "hadits_mean.startFind(null);"
label="Cari Terjemahan"/>
</popup>
<!-- ======================================================== -->
<!--
<window id="main-window">
<popupset id="mainPopupSet"></popupset>
<vbox id="hadits_holder" />
</window>
-->
<!--
<spacer flex="1"/>
<progressmeter mode="determined" value="82"/>
-->
<statusbar id="status-bar">
<statusbarpanel id="status-bar-inlinetrans"
src="chrome://inlinetrans/skin/imagesOn_kecil.png"
label="indonesia inline translator"
context="indonesia inline translator menu"
onclick="alert('okeh cuy')"
tooltiptext="inlinetrans versi 1.0"
/>
</statusbar>
</overlay>
You need an <image>. Something like:
<statusbar id="status-bar">
<statusbarpanel id="status-bar-inlinetrans">
<image src="chrome://inlinetrans/skin/imagesOn_kecil.png" />
</statusbarpanel>
</statusbar>
The other attributes can probably go on either the image or the statusbarpanel.

Resources