Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc....

27
Arc: AddIns Dr Andy Evans

Transcript of Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc....

Page 1: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Arc: AddIns

Dr Andy Evans

Page 2: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Java

Direct access to ArcObjects Framework inside and outside Arc.

Ability to add components to the GUI.

Ability to communicate with external applications.

Page 3: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

AddIns

Button : Icon on toolbar.Tool : Changes mouse operations.Combo box : Dropdown list and editable box.Toolbar : For grouping AddIns.Menu : Dropdown and right-click.Tool palette : Floating container for other AddIns. Dockable window : Floating window that can be locked into the GUI.Application extension : Additional functionality within, e.g. Arc extensions.

Page 4: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Form

jar zip file, with a .esriaddin extension

Contains:config.xml : metadata describing the addinJava class filesOther resources needed : e.g. data, images

Page 5: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Installing

File is just dropped into %USERPROFILE%\

My Documents\ArcGIS\AddIns\Desktop10.2 

or%USERPROFILE%\

Documents\ArcGIS\AddIns\Desktop10.2

There are easy install options for users (double clicking on the addin will bring up a wizard to walk through installing it)

Page 6: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Installing a sent AddIn

AddIn Manger

Page 7: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Choose “Add from file” and navigate to the file.

Should then see it under the commands list in whatever Category you’ve created for it in the XML file.

Drag and drop from here, onto the interface.

Installing a sent AddIn

Page 8: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Managing AddInsAdmin Registry Keys (regedit.exe)HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\Desktop10.2 \ Settings

BlockAddIns0 - Load all.1 - Load signed only.2 - Load ESRI only.3 - Load from administrator folders only.4 - Do not Load any Add-Ins.

AddInFoldersAdminAddInLock - stop tampering with these.

Page 9: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Digital signing

See:http://help.arcgis.com/en/sdk/10.0/Java_AO_ADF/conceptualhelp/engine/index.html#/Digitally_signed_add_ins/0001000004zq000000/

Page 10: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Making an AddIn

Rather than writing the config.xml ourselves, and zipping it up manually with the java files, there’s an Eclipse IDE plugin.

This does all the basic class generation for us, and prepares the file.

Details for installing the IDE and plugin on the website.

Page 11: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Eclipse

Page 12: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

EclipseProject area

Editor area, currently showing config.xml, but shown as a form, not text.

Show xml textsource

Page 13: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Config.xml

Page 14: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
Page 15: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
Page 16: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
Page 17: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
Page 18: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Eclipse

Should check code as you write.Will compile when you save the file.Errors reported in problems panel:

Note that the javadoc panel displays the javadocs of known classes.

Page 19: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Eclipse

Will autocomplete as you type. Will also suggest potential quick fixes if you click on hover over an issue.

Page 20: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Debugging

No System.out.println();

Best bet is:JOptionPane.showMessageDialog(null, String);

E.g.JOptionPane.showMessageDialog(null, "Hello World");

Or for exception checking…catch (Exception e){

JOptionPane.showMessageDialog(null, e.getStackTrace());

}

Page 21: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Help coding

Course Code CookbookThere’s no point in you struggling to find key bits of

code on ESRI’s site.So, there are many useful code examples, stripped

down to be a simple as possible, on the course website.

The quid pro quo:Send us useful code you get working.Read and try and understand the code, don’t just cut-

and-paste it. Ask questions!

Page 22: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Help codingIntro to Eclipse:

Help -> Welcome -> Overview / Tutorials

Arc Programming pages:http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/

Java ArcObjects Developer Guide -> Developing extensions -> ArcGIS Desktop customizations using add-ins

Page 23: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Help codingAPI:http://resources.arcgis.com/en/help/arcobjects-java/api/arcobjects/index.html

Note that the API docs are a re-write of the VB pages, and still contain some VB code:

If it says “This parameter is optional”, it usually isn’t.

If it says “If you don’t want this parameter, just pass in zero” or “Nothing”, then pass in null.

If it gives Variant as a return type, it returns java.lang.Object.

Page 24: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Select the AddIn

Page 25: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

If you are developing, you need to reboot Arc to get changes to appear, but you don’t need to re-add the addIn.

Page 26: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Extensions

Classes that extend Arc functionalityCustom feature renderers Custom geoprocessing tools : can be added to

ArcToolbox and ModelBuilderClass extensions : Change form of dataPlug-in data sourcesUtility objects : Combine other tools

Page 27: Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.

Installing

Jar file placed in<ArcGIS Install Dir>/java/lib/ext