arcgissamples\addins\extension\MapExtension.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.addins.extension; import java.io.IOException; import com.esri.arcgis.addins.desktop.Extension; import com.esri.arcgis.arcmapui.IDocumentEventsAdapter; import com.esri.arcgis.arcmapui.IDocumentEventsOpenDocumentEvent; import com.esri.arcgis.arcmapui.IMxDocument; import com.esri.arcgis.arcmapui.MxDocument; import com.esri.arcgis.framework.IApplication; import com.esri.arcgis.framework.IDockableWindow; import com.esri.arcgis.framework.IDockableWindowManager; import com.esri.arcgis.framework.IDockableWindowManagerProxy; import com.esri.arcgis.interop.AutomationException; import com.esri.arcgis.system.UID; public class MapExtension extends Extension { IDockableWindow win; IDockableWindowManager dwm; UID uid; IMxDocument mxDoc; int magic=0; // This is called upon Extension's startup @Override public void init(IApplication app) { try { dwm = new IDockableWindowManagerProxy(app); uid = new UID(); uid.setValue("dockableMap"); win = dwm.getDockableWindow(uid); mxDoc = (IMxDocument) app.getDocument(); // Add an event adapter to the map document ((MxDocument) mxDoc).addIDocumentEventsListener(new IDocumentEventsAdapter(){ // wire the opendocument event with the dockbale window.So when you open // a new document it will pop-up the dockable window. @Override public void openDocument(IDocumentEventsOpenDocumentEvent arg0) throws IOException, AutomationException { if (win != null){ win.show(true); } }}); } catch (Exception e) { e.printStackTrace(); } } }