Select to view content in your preferred language

Detecting a change of network analyst layer in a Toolbarbean control

545
1
01-17-2011 10:17 PM
AlexandreHirzel
Occasional Contributor
Hello,

I am developing a visual app using the ArcObjects Java API. I have a ToolbarBean, with a ControlsNetworkAnalystLayerToolControl item on it, which I use to select the network dataset that is going to be the subject of the app analyses.

I would like to have an event that detects when the user update that control, changing the current network dataset.

I have tried to use an onItemClick for the Toolbar, but it is not triggered by the NetworkAnalystLayer control.

Another solution could be to call a "Select data" dialog box similar to the one triggered by the ControlsAddDataCommand item but where only network datasets would be shown.

Or there might be another way to do that? Basically, I just want to select a network dataset and perform some preparatory analyses before giving the hand to the user.

I am new to ArcObjects programming and any help or pointer will be welcome. Thanks in advance.
0 Kudos
1 Reply
AlexandreHirzel
Occasional Contributor
I've found the answer, and I thought I might as well post it here, for those coming after me.

In the initialisation method, I put the following lines:

EngineNetworkAnalystEnvironment nae = new EngineNetworkAnalystEnvironment();
nae.addIEngineNetworkAnalystEnvironmentEventsListener(new IEngineNetworkAnalystEnvironmentEvents() {

  public void onNetworkLayersChanged(IEngineNetworkAnalystEnvironmentEventsOnNetworkLayersChangedEvent theEvent) throws IOException, AutomationException {
  }

  public void onCurrentNetworkLayerChanged(IEngineNetworkAnalystEnvironmentEventsOnCurrentNetworkLayerChangedEvent theEvent) throws IOException, AutomationException {
        onCurrentNetworkLayerHasChanged(theEvent);
  }
}


And then I wrote this event handler method:

private void onCurrentNetworkLayerHasChanged(IEngineNetworkAnalystEnvironmentEventsOnCurrentNetworkLayerChangedEvent evt){
  txtResults.append("Network layer has changed!");
}
0 Kudos