Programmatically Adding Add-In Components

552
4
02-02-2012 06:56 AM
JohnNielson
New Contributor
I have a custom Swing component inside a DockableWindow in ArcGIS.  I am currently using the Add-In framework.  I have a toolbar that I've created using the Eclipse plug-in, and I have assigned it an ID, say "TestToolbar."  However, I'm unable to get a reference to it using CommandBars, although it does show up in my list of toolbars in ArcMap.

I've tried the following code:

doc = this.app.getDocument();
   
ICommandBars commandBars = doc.getCommandBars();
   
ICommandItem commandItem = commandBars.find("TestToolbar", false, false);



For some reason, though, the ICommandItem reference is always null.  I want to add and remove the toolbar programmatically, so how can I get a reference to a toolbar created using the Add-In framework?


Any help would be much appreciated.



Thanks!

John
0 Kudos
4 Replies
JimHanks
New Contributor
Did you ever resolve this? My team is running into the exact same problem with 10.1 pre-release.

Thanks,
Jim Hanks
0 Kudos
JamesCrandall
MVP Frequent Contributor
I am very limited in Add-in development experience so apologies if this is not pertinent to your issue, but I came across this post that might help....

http://forums.arcgis.com/threads/909-Beta-10-Locating-AddIn-Extension-from-a-Button?highlight=add-in...
0 Kudos
LeoDonahue
Occasional Contributor III
This will find the GPS toolbar and delete it.

                // you need to get your own application reference for this next line...
                ICommandBars commandBars = application.getDocument().getCommandBars();
                UID commandID = new UID();
                commandID.setValue("esriArcMapUI.GpsToolBar");
                
                ICommandItem commandItem = commandBars.find(commandID, false, false);
                if(commandItem != null){
                    commandItem.delete();
                }
0 Kudos
JimHanks
New Contributor
Yes! And in C# it's even easier: ArcMap.Application.Document.CommandBars.Find - done!
0 Kudos