Disabling <action> in plugin develoipement - eclipse-plugin

In my application have a menu named Search, it is having sub menu named "Text" and the text sub menu also has a sub menu in that there is an action named 'Package' i.e., is created as action. this search menu is common for all perspectives.
i want to disable that action 'Packages' for particular particular perspective how to do that?
please help me.following is the code for menu creation and action
<menu
id="textSearchSubMenu"
label="Text"
path="org.eclipse.search.menu/fileSearchContextMenuActionsGroup">
<groupMarker
name="group2">
</groupMarker>
</menu>
<action
class="com.chinna.search.SPXTextSearchAction"
id="com.chinna.builder.SearchAction"
label="Packages"
menubarPath="org.eclipse.search.menu/textSearchSubMenu/group2"
pulldown="false"
retarget="false"
style="push">
<enablement>
<objectClass
name="org.eclipse.core.resources.IResource">
</objectClass>
</enablement>
</action>

Related

VBA - Ribbon customization - When adding an add-on

I did a program that I wished to distribute to my co-workers, they are not VBA oriented. So I wish to distribute it easily.
I created an Add-in, when install the add-in needs to create a custom Ribbon. I tried my best, but I cannot find easy to understand documentation.
My code is as follow :
Private Sub Workbook_AddinInstall()
On Error Resume Next 'Just in case
Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cControl
.Caption = "Open SCF workbook"
.Style = msoButtonIconAndCaptionBelow
.OnAction = "OpenTheCorrectFile"
.FaceId = 7720
.DescriptionText = "Open the SCF workbook"
End With
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cControl
.Caption = "Are they onboard"
.Style = msoButtonIconAndCaptionBelow
.FaceId = 5817
.OnAction = "Check_Suppliers_Already_On_Board"
.DescriptionText = "Check if suppliers have already been on boarded"
End With
End Sub
Now if you use my code you will notice that:
Buttons are small
Icons are small
No description when hoovering them
No special name for the new ribbon, it is call Add-ins
No special name for this group, it is call "Menu Commands"
Does anyone know how to solve this.
Whenever I am looking for those answer people are using special application to create the ribbons, I do not wish to do it. I am also a beginner in VBA, so everything that is easily digestible is welcome.
Thank you very much.
Here's an example of how you can do it without using any external application, just a text editor. But you will have to be careful to write XML code properly, or the excel file may not open correctly (make a backup copy).
You will create a folder named "customUI" and, inside that folder, a file named "customUI.xml"
You will write all your Ribbon details inside "customUI.xml". I wrote this example, covering the issues you listed: Big buttons and icons (Images list in https://bert-toolkit.com/imagemso-list.html) / Tooltip description (screentip and supertip) / Ribbon name (tab label) / Group names (group labels)
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="CustomTab" label="Add-ins">
<group id="Group1" label="Menu Commands">
<button id="Button1" label="Happy" size="large" screentip="Test1" supertip="Test1 description" imageMso="HappyFace" onAction="Macro1" />
<button id="Button2" label="Save" size="large" imageMso="FileSave" onAction="Macro2" />
<button id="Button3" label="{a}" size="large" imageMso="FieldCodes" onAction="Macro3" />
</group >
<group id="Group2" label="Other Commands">
<button id="Button4" label="Reply" size="large" imageMso="Reply" onAction="Macro4" />
</group >
</tab>
</tabs>
</ribbon>
</customUI>
Rename your .XLSM file to .ZIP, then you will be able to edit/add files. Add the customUI folder to the zip file.
From the ZIP file, extract the .rels file that is inside _rels folder, you will add this line between the last Relationship tag and the Relationships closing tag, and then put it back inside the ZIP file overwriting the .rels file there
<Relationship Id="someID" Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="customUI/customUI.xml" />
Rename the file back to .XLSM and open it, if everything is right, the new Ribbon will be there. It's important that the macros that will be called by the buttons have a control parameter, like this:
Sub Macro3(ByVal control As IRibbonControl)
That's it, everything about the UI is in the customUI.xml file, there is no more adding buttons in VBA. If you have to change something in the UI, you will have to rename it to ZIP again, overwrite the customUI.xml file and rename to XLSM again. Here's the Ribbon I got in this example:

How to dynamically update the label of a menu contributed to the org.eclipse.ui.menus extension

My eclipse plugin contributes a menu to the main menu. In it, is a sub-menu (selection) which in turn has some child elements (items). I would like to programmatically update the label of selection based on the selected item underneath. (see below)
File MyMenu Edit
─────┬─────────────────────┬──────────────────
│ Selection: Item B >│┌───────────┐
└─────────────────────┘│ Item A │
│ v Item B │
│ Item C │
└───────────┘
Using the command framework I was able to implement most of it (see below), but I can't figure out how to programmatically append the selection sub-menu with the text of its selected child.
Below are the relevant parts of the extensions to the plugin xml:
<extension point="org.eclipse.ui.commands">
<command
defaultHandler="menu_selector.DoSelectHandler"
id="command.do_select"
name="Select Option">
<commandParameter
id="command.do_select.option_value"
name="Option Value"
optional="false">
</commandParameter>
<commandParameter
id="command.do_select.persisted_value"
name="Persisted Value"
optional="false">
</commandParameter>
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="MyMenu">
<menu
id="menu.selection"
label="Selection: ">
<dynamic
class="menu_selector.ItemsProvider"
id="items">
</dynamic>
</menu>
</menu>
</menuContribution>
</extension>
In the class ItemsProvider, I implemented getContributionItems() to populate the items dynamic sub-menu with do_select commands.
The class DoSelectHandler implements IElementUpdater. The commands framework calls its updateElement(UIElement element, Map parameters) method for all commands in the items dynamic menu right before it displays it. I use it to call setChecked(true) on the relevant element parameter to set the v character in front of the selected item in the items dynamic menu.
This would also be a logical route to update the selection menu, but I can't see how I can accomplish that. Setting the commandId on the selection menu doesn't make the commands framework call updateElement() with the selection menu as its element parameter.
Does anybody have an idea how to go around this?
You can get more control with specifing your own class for menu contribution
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
class="org.examples.menu.VeryDynamicMenuFactory"
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
</menuContribution>
</extension>
The class should extend org.eclipse.ui.menus.ExtensionContributionFactory

VSTO Ribbon Context Menu Dynamic Hierarchy

How does one create a dynamic menu hierarchy using VSTO Ribbons (for Outlook 2016)?
The xml placeholder could look like this, but I need to add/remove a menu tree under the menu root (instead of dummySingle). It seems like there would need to be something like a "getDependents" callback for menu items.
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<menu id="Menu Root" label="Menu Root" >
<button id="dummySingle"
label="dummy"
onAction="DummyAction"/>
</menu >
</contextMenus>
</customUI>
You would need to look at Dynamic Menus for Office Ribbon. This would be great source for you to start with: Adding Custom Dynamic Menus to the Office Fluent User Interface. Your ribbon XML will looks like ...
<dynamicMenu id="dynamicMenu1"
label="Dynamic Menu"
getContent="GetContent" />
And on GetContent handler you will build dynamic menu contexts, may looks like ...
public string GetContent(IRibbonControl control)
{
StringBuilder MyStringBuilder = new StringBuilder(#"<menu xmlns=""http://schemas.microsoft.com/office/2006/01/customui"" >");
MyStringBuilder.Append(#"<button id=""button1"" label=""Insert Text"" onAction=""OnAction"" imageMso=""SignatureLineInsert"" />");
MyStringBuilder.Append(#"<menuSeparator id=""menusep1"" getTitle=""GetTitle"" />");
MyStringBuilder.Append(#"<button id=""button2"" label=""Insert More Text"" onAction=""OnAction"" imageMso=""FileDocumentInspect"" />");
MyStringBuilder.Append(#"</menu>");
return MyStringBuilder.ToString();
}
More on Dynamic Menus: documentation for dynamicMenu

Add standard command button "New Slide" to custom ribbon in office add-in

I have created my customized ribbon in an addIn. Now I would like to add the New Slide command that exist in home screen (see screenshot below).
You can add built-in controls to your custom tab by soecifying their IdMso values. See Office 2013 Help Files: Office Fluent User Interface Control Identifiers .
You can read more about the Ribbon UI in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I think after a lot of searching I finally figured it out!
This is all the code you need, delete everything else
This will create a new slide button just like the one that comes default in PowerPoint
<group id="add_slide" label="Add Slide">
<control idMso="SlideNewGallery" size="large" />
</group>
credit
i currently have new slide button in my addin like the image below which gives me a new slide
however I want the option like the already existing new slide in home ribbon where I can choose templates.Is there any way to invoke this button in my customized ribbon so below is my newslide that is what i want to get in my addin
private void New_slide_Click(object sender, RibbonControlEventArgs e)
{
PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
ppApp.CommandBars.ExecuteMso("SlideNewGallery");
}
I created a new ribbon based on xml Template in VS. Afterwards I added a group and a control based on an idMso-Value. When using this xml file
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab id="tab0" label="AddIn">
<group id="grpCustom">
<button idMso="SlideNew" size="large" label="YOUR CUSTOM TEXT"></button>
</group>
<group idMso="GroupSlides"></group>
</tab>
</tabs>
</ribbon>
</customUI>
This results in that custom ribbon. Eugene Astafiev pointed it out, you can find idMso-Values in MSDN.
As explained by Franz the solution is to use the idMso.
For the New Slide command you are looking for, if you look at MSN in the idMso Table for "New Slide" you will find two entries.
The one you are looking for is a Gallery with idMso=SlideNewGallery.
(not a button).
You can add it in the XML. I like to use the Ribbon Editor.
With the Ribbon Editor it looks like this:
And in the Add-In it looks then like this:
The CustomUI XML relevant part looks like this
<group id="TD_GrpMisc" label="Misc">
<gallery
idMso="SlideNewGallery"
size="large"/>
<button
idMso="SlideNew"
size="large"/>
</group >

VBA error 'Wrong number of arguments or invalid property assignments' when running macro via custom button

I have a macro that I call via a tab/group/button added by the Custom UI Editor -
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="tabCustomActions" label="Custom ActionsXXX" insertAfterMso="TabDeveloper">
<group id="GroupTLA" label="TLA Actions">
<button id="buttonFormatTLA" label="Format as TLA" image="TLALogo" size="large" onAction="start_tla" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
The button shows up just fine, with my custom logo, but when ever I click the button I get the follow error -
VBA is not opened following this error, as it usually is, and no code within VBA is indicated as the problem if I open the developer console and then try and click the button.
Strangely though, if I try and run the macro manually, it works fine with no errors. Does anybody have any ideas how to solve this?
Here is my full code in a Pastebin, should you wish to view it. Thanks.
You have the wrong call signature for the start_tla callback in your VBA code.
If you open up your file in Custom UI Editor, there is a button called Generate Callbacks to the right in the menu. If you press it, it will give you the correct callbacks for your VBA code to match the ribbon xml in your file:
'Callback for buttonFormatTLA onAction
Sub start_tla(control As IRibbonControl)
'Your code goes here
End Sub
According to the Pastebin link, your sub looks like this, without the control As IRibbonControl parameter:
Public Sub start_tla()
It is old thread, but maybe it will help someone.
If you make 'control' argument optional, you can run either from Ribbon button or directly from VBA or Form button.
Sub start_tla(Optional control As IRibbonControl)
'Your code goes here
End Sub