×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

INDI for Java - INDISwitchOneOfManyProperty

  • Posts: 1
  • Thank you received: 0
Hi,

First of all many thanks for INDI and INDI for Java. These projects are simply great. However, I'm facing a problem with getting the selected value of an INDISwitchOneOfManyProperty. In the method processNewSwitchValue I try to get the selected value by using the following code:
if (indisp == pObjectCatalogue)
{
	if (indsvs.length > 0)
	{
        	System.out.println("Selected value: " + pObjectCatalogue.getSelectedValue());
	}
}
The problem is that the value of the first element of the drop down list is always printed even if an other element is selected. The same with the index of the selected element.

The property is instanced in the constructor of my INDI driver with the following line:
pObjectCatalogue = new INDISwitchOneOfManyProperty(this, "pObjectCatalogue", "object catalogue", "Alignment", PropertyStates.IDLE, PropertyPermissions.RW, new String[0]);

As my programme always crashes when I try loading the values for this property out of my MySQL database, I fetch the values in the driverConnect method and recreate the property before adding it, as you can see in the code snippet below:
alLuminaries = DatabaseOperations.getAllLuminaries();
String[] aLuminaries = new String[alLuminaries.size()];
for (int i = 0; i < alLuminaries.size(); i++)
{
	aLuminaries[i] = alLuminaries.get(i).getName();
}
try
{
	pLuminary = new INDISwitchOneOfManyProperty(this, "pSelectedLunarObject", "lunar object", "alignment", PropertyStates.IDLE, PropertyPermissions.RW, aLuminaries);
	this.addProperty(pLuminary);
}
catch (INDIException indiError)
{
	System.out.println(String.format("An error occured while updating the luminary list: {0}", indiError.getMessage()));
}

aLuminaries is an Array of Strings and alLuminaries is an ArrayList.

Many thanks for your support!
Last edit: 10 years 5 days ago by Lukas.
10 years 5 days ago #982

Please Log in or Create an account to join the conversation.

Time to create page: 0.367 seconds