Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] ToolManager and finding tools

Hi uDiggers,

I'm using uDig as the mapping component of a larger project to track and manage Patrol data. The quick summary is - Rangers (or others) take GPS devices into the field (park or protected area) and record information (wildlife sightings, poaching sighting) using these devices. The application then provides the ability to download, manage, and report on the information collected.

So far I've had little trouble integrating uDig - so thanks to everyone.

I have one question - I'm developing a very simple map view that is not meant to be used for anything other than quickly viewing data. I want it to only have a few simple tools (pan, zoom and possibly one or two custom tools). As a result I'm creating my own custom toolbar with the set of tools I need.

I want to use the ToolManager to find the defined tools and add them to my custom toolbar. I tried using the ToolManager.findTool(toolID) function but it doesn't search non-modal tools and it doesn't return the tool proxy (that contains the name, image and other information I need).

The solution I came up with was to add a function to the ToolManager called findToolProxy(toolId) [as shown below]. This function searchs all tools (modal, action and background) and returns the associated toolproxy. This function would also need to be added to the IToolManager.

If there is some better way of accessing the Tool extensions please point me at it and I'll have a look. Otherwise, (if I create a patch and submit it via git) would it be possible to get this update into udig?

Thanks,
Emily




 /**
     * Find a tool proxy with the provided ID.
     * <p>This searches modal tools, background tools, and
     * action tools</p>
     * @param toolID toolId to search for
     * @return ToolProxy of tool if found or null
     */
	public ToolProxy findToolProxy(String toolID) {
		for(ModalToolCategory category : modalCategories){
			for (ModalItem item : category) {
				if(toolID.equals(item.getId())){
					return (ToolProxy)item;
				}
			}
		}
		for(ActionToolCategory category : actionCategories){
			for (ModalItem item : category) {
				if(toolID.equals(item.getId())){
					return (ToolProxy)item;
				}
			}
		}
		for(ToolProxy item : backgroundTools){
			if(toolID.equals(item.getId())){
				return (ToolProxy)item;
			}
		}
		return null;
	}






Back to the top