Adding tool tips to Add-In Menu in Enterprise Architect through API - menu

I am working on Enterprise Architect with C# Add-Ins. I am trying to check the Add-In menu item and also add tool tip to display information about that feature.
I tried the following code :
public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
{
//Enables the menu if the project is open
if (IsProjectOpen(Repository))
{
IsEnabled = true;
if (ItemName.Equals("Help"))
{
//check the menu
IsChecked = true;
}
}
The menu item check works fine but unable to find an option to add tool tip to the menu.
I referred this link:
https://sparxsystems.com/forums/smf/index.php?topic=4129.0 where a feature request for tool tips is mentioned.
Is is possible to set menu tool tip through Add-in in EA Version 12.1?

No, that is not possible.
You can send in your own feature request in order to add weight to the request.

Related

How to add a New Action to the mobile App

Good day
Build 20.107.0026
I have created a New Action and want to add it to my Mobile app. Is it possible to add a custom action to a mobile screen? I have created the below action in the Appointment screen(FS300200)
namespace PX.Objects.FS
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class AppointmentEntry_Extension : PXGraphExtension<AppointmentEntry>
{
#region Event Handlers
public PXAction<PX.Objects.FS.FSAppointment> DoWork;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "DoWork")]
protected void doWork()
{
}
#endregion
}
}
Mobile code below. If I want to add the button to the main menu; the 3 dots on the side do I use AppointmentRecords as the container?
update screen FS300200 {
update container "AppointmentRecords" {
add listAction "StartTravelAPICall" {
behavior = Void
displayName = "StartTravelAPICall"
}
}
}
The short answer is YES! The long answer depends in part on what version of Acumatica you are using. For the purpose of this answer, I'll assume you are in 2019R2 and already know how to add or edit a Mobile App screen in Acumatica. If not, the training guides referenced below should give you all the detailed information you need to accomplish your goal.
Manipulating the Mobile App screens/actions is relatively easy if the screen/action works in the browser interface. The T410 course material explains how to add an action in 2019R2. I don't work with Field Services, so I'll have to explain more generically as per the training guide.
First you must either add or edit the screen in the Mobile Application section of the Customization Project. (In your case, you want to Update the existing screen.) This will create a section of code in the customization project that looks like this:
As you can see, the original screen definition in the mobile app is shown on the right, and you will be updating the screen to add your action. You will need to add the appropriate container (not shown in your question) and then the action within that container.
To continue the answer, let's switch to the training guide example on page 12 of the T410 course updating the SO303000 screen. You can compare to your screen to see what needs to be changed.
add container "InvoiceSummary" {
# fields declaration
…
add recordAction "Save" {
behavior = Save
}
add recordAction "Cancel" {
behavior = Cancel
}
add containerAction "Insert" {
behavior = Create
}
add recordAction "ReleaseAction" {
syncLongOperation = true
behavior = Record
}
}
I believe your action would follow the ReleaseAction portion at the bottom of the example, and the need for syngLongOperation = true would depend on what your action is doing (i.e. if you need the action performed asynchronously).
Assuming your container is already defined in the page, which I suspect it is, let's instead look at the example for PO302000 on page 35. This example shows how to UPDATE a container to add your action.
update screen PO302000 {
update container "DocumentSummary" {
add recordAction "AddPOOrderLine" {
displayName = "Add PO Line"
behavior = Void
redirect = True
redirectToContainer = "AddPurchaseOrderLine$List"
}
}
}
That was a more complex action, but yours may be as simple as.
update screen FS300200 {
update container "ServiceOrderTypeLine" {
add listAction "DoWork" {
Behavior = Void
displayName = "Do Work"
}
}
}
If you need guidance on how to read the WDSL Schema to identify the container, etc. that training is found in T400 starting on Page 13.
I highly recommend reviewing both T400 and T410 if you are working with the mobile app as there is a lot more detail in those training guides than can be explained easily in a Stack Overflow post/answer.

Creating a navigation menu item in Orchard

I have written an Orchard Module and would like an item to appear in a Navigation list when the module is Enabled. Ideally, I would like to be able to remove the item when the Module is disabled.
Where should I hook into to for when the module is enabled and disabled?
How do I programmatically add a menu item to an already existing Navigation?
You can implement the IMenuProvider interface for this. An example implementation might look something like this:
namespace Orchard.Bar {
public class SuperMenuProvider : IMenuProvider {
private readonly IOrchardServices _orchardServices;
public SuperMenuProvider(IOrchardServices orchardServices) {
_orchardServices = orchardServices;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public void GetMenu(IContent menu, NavigationBuilder builder) {
string position = "10";
builder.Add(T("Foo"), position, item => item.Url("http://foo.com").AddClass("someClass"));
builder.Add(T("Bar"), position + ".1", item => item.Action("Index", "Foo", new { area = "Orchard.Bar" }));
if (_orchardServices.Authorizer.Authorize(Orchard.Security.StandardPermissions.AccessAdminPanel)) {
builder.Add(T("Secure FooBar"), position + ".2", item => item.Action("Index", "Secure", new { area = "Orchard.Bar" }));
}
}
}
}
This will appear on all menus on the front end. You may want to put in the name of the menu you are targeting if you know for sure that is what it is called (default in Orchard is "Main Menu", people don't generally change it to be honest). This could be a little brittle, so you may want it customizable, either with a site setting or you could create a part that you attach to the menu content type that lets the admin specify whether to show your menu items on the said menu.
An alternative approach would be to hook into the modules enable event using IFeatureEventHandler and using the content manager to create menu items with urls and adding them to a specified Menu. I don't really recommend this approach; you lose control of the menu items (e.g. to update a url), they can be removed from the menu accidentally, you have to know the name of the Menu you are adding them to, you are more limited (cant do permissions checks etc.).
I assume you are talking about showing up on the front end. If you talking about the admin menu then check out pretty much any module for a file generally called AdminMenu.cs, plenty of examples :)
The question doesn't specify what the module does so I guess we're to assume that it creates a content type. In that case you have (at least) two options:
In the Content Type's Content Definition go to Add Parts and add the Menu part. This will allow you to add a content item to a menu from the item's content editor.
From the Navigation menu choose the appropriate Menu and select add a Content Menu Item. Note that the content type must be set as "listable" in Content Definition in order for the items to be listed as a choice.
Disabling the module should remove the item from the navigation in either case.

Excel Custom Task Pane not showing

I'm showing a custom task pane in an excel VSTO add-in, I'm building it and showing it as thus:
var ctrl = new CellTaskPane();
var pane = CustomTaskPanes.Add(ctrl, "Custom Sheet");
pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
pane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
pane.Visible = true;
This is being done in the ThisAddin.cs file and it working just fine on my machine, both under a Debug session and with the add-in installed via the click-once installer.
However, installing the add-in on a colleague's machine is proving troublesome.
The add-in is functioning and the context menu / ribbon is working perfectly, but the pane just refuses to show.
I have a toggle button on the ribbon which toggles the Visible property on the pane and even clicking that isn't forcing the pane to show.
Any help on this would be greatly appreciated, Google is proving useless for this.
Thanks.
I should mention that CellTaskPane is just a UserControl as per the docs on MSDN: http://msdn.microsoft.com/en-us/library/aa942846.aspx
Turns out it wasn't anything we were doing directly!
There was another add-in installed (third party) which for some bizarre reason was interfering with the pane being shown (no idea why or how).
Shame that Excel doesn't show any sort of error or at least throw an exception.
Ah well.
I suggest you try a very, very simple custom task pane first to see if this works. I put together the most simple example I could think of, basically a single text box that gets a value pushed into it and this is returned to the ribbon when a button is pushed.
If you were to try this then I would do it as a new solution. Create a new VSTO project with a "Designer mode" ribbon. Add a toggle button and a normal button below it. Then copy in this code:
ThisAddIn.cs
using System;
using Office = Microsoft.Office.Core;
namespace ExcelAddIn1
{
public partial class ThisAddIn
{
private Microsoft.Office.Tools.CustomTaskPane pane;
private CellTaskPane ctrl = new CellTaskPane();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
pane = CustomTaskPanes.Add(ctrl, "Custom Sheet");
pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
pane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
pane.Visible = true;
pane.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged);
ctrl.SetName("test");
}
private void taskPaneValue_VisibleChanged(object sender, System.EventArgs e)
{
Globals.Ribbons.Ribbon1.toggleButton1.Checked = pane.Visible;
}
public Microsoft.Office.Tools.CustomTaskPane TaskPane
{
get
{
return pane;
}
}
public CellTaskPane MyContainer
{
get
{
return ctrl;
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
Add a new class called CellTaskPane.cs:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
namespace ExcelAddIn1
{
public class CellTaskPane : System.Windows.Forms.UserControl
{
public System.Windows.Forms.TextBox test;
public CellTaskPane()
{
InitializeComponent();
}
public void InitializeComponent()
{
test = new System.Windows.Forms.TextBox();
test.Location = new System.Drawing.Point(120, 8);
test.Size = new System.Drawing.Size(232, 20);
test.TabIndex = 0;
Controls.AddRange(new System.Windows.Forms.Control[] { test });
Size = new System.Drawing.Size(375, 150);
}
public void SetName(string text)
{
test.Text = text;
}
public string GetName()
{
return test.Text;
}
}
}
Add the following code to Ribbon1.cs:
using System;
using Microsoft.Office.Tools.Ribbon;
namespace ExcelAddIn1
{
public partial class Ribbon1
{
private void toggleButton1_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.TaskPane.Visible = ((RibbonToggleButton)sender).Checked;
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
button1.Label = Globals.ThisAddIn.MyContainer.GetName();
}
}
}
Obviously you will need to do a little tweaking to get this to work, I tried to take the default names for a new project and the buttons.
When you run this you should get a custom task pane. When you switch to the "TabAddIn" and click the toggle button it should show/ hide the task pane. When you click the normal button the contents of the only field in the task pane should be copied as the button name. I defaulted this to "test", so even if the task pane isn't visible you can see if it is in memory or not?
I tested this and it appears to work fine. Basically this is just a hacked up version of the examples on MSDN. If you wanted you could probably do this yourself anyway? If nothing else this will enable you to see if there is anything in the more complex ribbon you are working on that causes issues... or if this is a fundamental problem with your colleague's machine.
I had the same problem, but it was not any addin I could disable (COM+ or Excel).
I had my excel configured to open files at startup
(Excel Options -> Advanced -> General)
There, I had an .XLAM that customized the ribbon.
When I cleared this configuration, my addin started working.
I ran into exactly this problem while trying to get the Microsoft sample code for "Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button" working. Here's a link to the page:
http://msdn.microsoft.com/en-us/library/bb608590.aspx
After starting from scratch about three times and scouring the Internet for a clue as to what I might have been doing wrong, I came across this question and Clint's answer that an add-in was causing his problem. I had a few add-ins enabled, but with some trial and error I found the culprit: Microsoft's own "Analysis Toolpack"!
Once I disabled Analysis Toolpack, the custom pane started appearing and disappearing as expected.
So, as Clint discovered, the first thing you should probably try if you run into this issue is to disable all add-ins and see if that does the trick. If so, then you can go back and begin turning them on until you find the one that is interfering with your custom pane visibility.
Well, after following #GaryP's advice, disabling my other add-ins, and thinking that I'd solved the problem (albeit without access to my other add-ins), I discovered that the add-in would disappear whenever I opened more than one workbook.
But at that point, I didn't just get a missing taskpane or a silent fail, I actually got an error:
The taskpane has been deleted or is otherwise no longer valid
So it seems that disabling add-ins isn't solving the problem in itself, but rather disabling add-ins is reducing the number of open workbooks (even if add-ins aren't visible, they can still have a Ribbon handle)...
The underlying cause is the use of SDI in 2013 and later.
So, now I can have all of my add-ins loaded.
Create a new instance of the task pane for each workbook. Make the following changes to your code and the task pane works even with addins enabled.
private void Application_WorkbookActivate(Microsoft.Office.Interop.Excel.Workbook wb)
{
pane = CustomTaskPanes.Add(ctrl, "Custom Sheet");
pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
pane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
pane.Visible = true;
pane.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged);
ctrl.SetName("test");
}
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WorkbookActivate += new Excel.AppEvents_WorkbookActivateEventHandler(
Application_WorkbookActivate);
}
If you find that even after closing all other add-ins, the TaskPane still doesn't show, it may be because it is loaded in your "Personal.xlsb" workbook. After closing it, I tried making the pane visible again and I received an error that it had been closed.
I had the same problem and didn't fix it by disableing the analysis toolpack, but, rather i had to move the XLAM out of its installed folder (Break the reference to it, since you couldn't remove it through Excel) and it started working.
I've sense added the files back and it continues to work. Activating the addin does cause my custom taskbar to break. Not sure what this long term fix is here.
I know this is very old, but it can be useful for anyone who may look up for an answer, but here we go:
if you are adding the new taskpane under ThisAddIn_Startup, it will only add it once at the start of the excel, and it will not be present for any other Excel session, so based on the following link that shows how to handle multiple sessions:
https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb264456(v=office.12)?redirectedfrom=MSDN#Anchor_2
I came up with the conclusion that I should create a new taskpane under the other events that can fire when I needed the taskpane, then validate if the current window has the taskpane or not, and create a new one if not and show it. the event can be any trigger like ribbon button, open document, etc.
Dim CurrentTaskPane As Microsoft.Office.Tools.CustomTaskPane = Nothing
Globals.ThisAddIn.RemoveOrphanedTaskPanes() 'to remove any unused taskpane
For Each ctp As Microsoft.Office.Tools.CustomTaskPane In Globals.ThisAddIn.CustomTaskPanes
If ctp.Window.Hwnd = Excel.Application.ActiveWindow.Hwnd Then
CurrentTaskPane = ctp
Exit For
End If
Next
If CurrentTaskPane Is Nothing Then
CurrentTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(New ControlName, "My TaskPane", Excel.Application.ActiveWindow)
End If
CurrentTaskPane.Visible = True
You can find the 'RemoveOrphanedTaskPanes' code from the link provided.
Summarizing other answers: It appears that this is due to loading other Add-ins, .XLAM files, etc. These can be loaded from many different places, and you need to check them all, and remove them. You may be able to reenable them later, so back everything up. Here is a checklist:
File -> Options -> Advanced -> General -> "At startup, open all files in..." Remove those files and disable the option.
File -> Options -> Add-ins -> Check all the Active application add-ins. Near the bottom of the dialog, use the Mange: Excel/Com Add-ins to view the Add-ins and disable or remove them. Even the Microsoft included ones could be causing it, so disable them as well. They do not allow you to remove them, which is fine, as long as they are disabled.
C:\Users\$USERNAME\AppData\Roaming\Microsoft\Excel\XLSTART Remove all files from this directory.
C:\Users\$USERNAME\AppData\Roaming\Microsoft\AddIns Remove all files from this directory.
After this, try again to load the Add-In. Then, add back the things you need one by one and keep testing. They may break it again, or not, there does not appear to be consensus on what kind of Add-In does and does not break the task pane.
If anyone discovers more places to look for Add-Ins, I will add them to the list.

Determining which Visual Studio context menu was selected?

I'm writing a VS2012 add-in, adding a command to Build Explorer context menu (see related question). The command gets added to 2 different context menus:
Build Explorer
Team Explorer, Builds page, My Builds section
When my one callback is called, how do I know which of these it is?
I tried get the focused control (using P/Invoke as this question suggests). However, it gets me a Tabs container for (1), and null for (2). I could try to cast the control to the tabbed container, but that sounds pretty bad...
Any better alternative?
My new/other idea - it is similar to yours:
You should try to monitor which window was activated lastly.
If you create an eventhandler for your command, then you may be able to check which window is active when your command fired. A simple evenent handler for a command:
void cmdEvents_BeforeExecute( string guid, int ID, object customIn, object customOut, ref bool cancelDefault )
{
Window2 teamExplorer = _applicationObject.Windows.Item("Team Explorer") as Window2;
if (_applicationObject.ActiveWindow.Caption == teamExplorer.Caption)
{
//You are called from Team Explorer
}
else
{
//Somewhere else
}
}
And the way you can subscribe:
static _dispCommandEvents_BeforeExecuteEventHandler _myHandler;
static CommandEvents _cmdEvents;
public void OnConnection(...)
{
Command command = ...; // Init your command
int ID = command.ID;
string GUID = command.Guid;
CommandEvents _cmdEvents = _applicationObject.Events.get_CommandEvents(GUID, ID);
_myHandler = new _dispCommandEvents_BeforeExecuteEventHandler(cmdEvents_BeforeExecute);
_cmdEvents.BeforeExecute += _myHandler;
}
You may find a better way to identify the window(s) by GUID. You should keep at least _cmdEvents as static because when it will be desroyed, your event handler could vanish (least for internal commands).
In OnDisconnection you should unsubscribe.
Reworked by the comment, and founded links:
As the menu item is shown every place it seems there is no way to distinct between them from an Add-In, you should add two command and distinct them by their context.
The way instead of converting the Add-In to a VS-Package MZ-Tools HOWTO: Controlling the state of command in a Visual Studio add-in, try MZ-Tools HOWTO: Use the IVsMonitorSelection ... you can also get it from an Add-In.
But:
Neither the AddNamedCommand nor the QueryStatus methods honor the
invisible state: the button that must be invisible ...
remains disabled rather than invisible.
I think this makes it impossible to do it from an Add-In on a suitable way, but maybe you can check the contexts.
Other way you could get further, if you try to migrate your command/menu into a VSPackage and create a custom UIContext for the menu items or find a suitable predefined one. I have no access to a Studio enhanced with Build Explorer so I can't try it.
The following discussion is about custom contexts for vs-packages:
http://davedewinter.com/2008/04/05/dynamic-menu-commands-in-visual-studio-packages-part-3/
Sadly the links are broken from the post, and I can't reach Part 1. and Part 2. which is about the discussion of the problem from the beginning.
But there is no guarantee you can create a context which suits you.
Only context ID I found for Team Explorer is the guidTeamProjectCmdUIContext.
It is placed at vsshilds.h in Visual Studio 2010 SDK, vsshell*.h are also contain several others.
MSDN: Vsct files to define command, menus, ect. from packages.
Condition attribute for items:
http://msdn.microsoft.com/en-us/library/bb491718.aspx
http://msdn.microsoft.com/en-us/library/bb166515.aspx
MSDN: VisibilityItem element for commands and toolbars.
VisibilityItem element determines the static visibility of commands and toolbars.
... After the VSPackage is loaded, Visual Studio expects command visibility to be determined by the VSPackage rather than the VisibilityItem.
And finally about predefined Context Guids:
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.uicontextguids80.aspx
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.uicontextguids.aspx

Eclipse RCP: How to configure the Perspective Menu?

I need to have total control of the perspective menu.
I already hacked into the platform to disable the CONTEXT menu:
private void disablePerspectiveToolbarMenu() {
PerspectiveBarManager perspectiveBarManager =
((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar();
if (perspectiveBarManager!=null){
ToolBar toolBar = perspectiveBarManager.getControl();
Listener[] listeners = toolBar.getListeners(SWT.MenuDetect);
if (listeners != null){
for (Listener listener : listeners){
toolBar.removeListener(SWT.MenuDetect, listener);
}
}
}
}
But i need also to control the default contents of the PERSPECTIVE MENU. There is one option that is always present that gives access to a Perspective List Shell. I need to remove that option from the menu.
It's a shame that the perspective menu is totally out of user control. I just need to have the perspectives added to the menu, and nothing more!
Thanks.
There are 3 potential options to get rid of Other:
Set the
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU
preference to false in your RCP app. This can be done by including a plugin_customization.ini file with your product definition.
Patch the workbench in your RCP app.
Have a look at
org.eclipse.ui.internal.PerspectiveBarNewContributionItem
and
org.eclipse.ui.actions.ContributionItemFactory.PERSPECTIVES_SHORTLIST
Don't include the default
perspective bar in your RCP app.
Instead, create a perspective bar
using org.eclipse.ui.menus, a
toolbar, and the openPerspective
command.
I did some research and the solution did not work as I expected it. Finally I found my mistake.
To set the property in the plugin_customization.ini I tried:
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU=false
but this is not the correct notation!!! Please see the correct solution I added finally to the plugin_customization.xml
org.eclipse.ui/SHOW_OTHER_IN_PERSPECTIVE_MENU=false
So the name of the interface or the class specifying the property ist not part of the notation!

Resources