Select to view content in your preferred language

Creating object by name in Java

523
2
01-02-2013 08:36 PM
ModyBuchbinder
Esri Regular Contributor
I am developing an Engine Java application.
I would like to use the ready-to-use buttons but I do not like the toolbar control.
I used the techniques described here: http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/0001/000100000785000000.htm under the "Control commands without the ToolbarBean" subject but I changed the code a little to look like this:
ICommand c = (ICommand)new ControlsSelectFeaturesTool();
This works nicely.
Now I would like to create my buttons dynamically by some configuration file.
I would like the software to read the file and create the buttons by the names found in the file.
For example if the string in the file is "Controls.ControlsSelectFeaturesTool" I would like to run something like this:
ICommand c = (ICommand)CreateObject("Controls.ControlsSelectFeaturesTool")

Can somebody explain if this can be done and how?

Thanks
Mody
0 Kudos
2 Replies
MarcinDruzgala
Frequent Contributor
I am developing an Engine Java application.
I would like to use the ready-to-use buttons but I do not like the toolbar control.
I used the techniques described here: http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/0001/000100000785000000.htm under the "Control commands without the ToolbarBean" subject but I changed the code a little to look like this:
ICommand c = (ICommand)new ControlsSelectFeaturesTool();
This works nicely.
Now I would like to create my buttons dynamically by some configuration file.
I would like the software to read the file and create the buttons by the names found in the file.
For example if the string in the file is "Controls.ControlsSelectFeaturesTool" I would like to run something like this:
ICommand c = (ICommand)CreateObject("Controls.ControlsSelectFeaturesTool")

Can somebody explain if this can be done and how?

Thanks
Mody


Well it depends how much buttons you want to dynamically create with this file. If the amount is limited and you as a programmer know which buttons user will define, i would do this like this:
switch(toolName) // toolName is a string from file
{
      case "Controls.ControlsSelectFeaturesTool":
          ICommand c = (ICommand)new ControlsSelectFeaturesTool();
          //more logic etc
          break;
      case "":
          //....
          break;
}


Hope this helps at least a bit.

Regards
MDruzgala
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Hi MDruzgala

Thanks for your response.
I already consider this option. I would like the configuration to be able to get any ready-to-use button.
For this I need very long switch.
I am looking for something similar to what ObjectFactory.Create do, this interface is part from the framework library so I cannot use it in Engine.

Mody
0 Kudos