I think the optimal place to insert the code to re-number load priorities would be in the com.affymetrix.igb.general package in the file:
DataProviderTableModel.java.
The new code should probably go in the sortDataSources function. If that function is called overly often (at times when we might not want to re-number the load priorities) then the re-number can be its own function, probably still in that file and it would start by calling the sortDataSources. Before implementing this change, we would need to get a complete view of where sortDataSources is called.
public void sortDataSources()
{
sortedDataProviders = Lists.newArrayList(DataProviderManager.getAllServers());
Collections.sort(sortedDataProviders, new DataProviderComparator());
ThreadUtils.runOnEventQueue(() -> fireTableDataChanged());
}
This code is not run until the Data Sources table is opened (so we will probably avoid colliding with the initial start-up period where only some of the data providers have been loaded). Since the Data Sources table is the only place where a user can change the load priority of the data providers, this is an optimal place for code that ensures the functionality of that feature.
The code that is executed when the up/down buttons are pressed is spelled out in DataProviderManaementGui.java, in the functions initLoadPriorityUpBtn and initLoadPriorityDownBtn respectively. Each of these calls the sortDataSources function.
So if the re-numbering is part of sort, then its already set to be triggered by these events.
We also need to make sure the re-numbering code is triggered by the adding or removing a data provider.
The add function is handled by the AddDataProvider class though a function called addServerButtonActionPerformed. The code to remove a data provider is in the DataProviderManager class in a function called: removeDataProvider.
Both end with this call:
eventBus.post(new DataProviderServiceChangeEvent());
I don't know how this DataProviderServiceChangeEvent object works, but I think it might be helpful. If this is meant to signal that the set of data providers has changed, then we need to find whatever code it triggers and make sure our sort and re-number code in triggered by it. Something like that would be cleaner than adding code to each function to call the sort function.
I think the optimal place to insert the code to re-number load priorities would be in the com.affymetrix.igb.general package in the file:
DataProviderTableModel.java.
The new code should probably go in the sortDataSources function. If that function is called overly often (at times when we might not want to re-number the load priorities) then the re-number can be its own function, probably still in that file and it would start by calling the sortDataSources. Before implementing this change, we would need to get a complete view of where sortDataSources is called.
public void sortDataSources()
{ sortedDataProviders = Lists.newArrayList(DataProviderManager.getAllServers()); Collections.sort(sortedDataProviders, new DataProviderComparator()); ThreadUtils.runOnEventQueue(() -> fireTableDataChanged()); }This code is not run until the Data Sources table is opened (so we will probably avoid colliding with the initial start-up period where only some of the data providers have been loaded). Since the Data Sources table is the only place where a user can change the load priority of the data providers, this is an optimal place for code that ensures the functionality of that feature.
The code that is executed when the up/down buttons are pressed is spelled out in DataProviderManaementGui.java, in the functions initLoadPriorityUpBtn and initLoadPriorityDownBtn respectively. Each of these calls the sortDataSources function.
So if the re-numbering is part of sort, then its already set to be triggered by these events.
We also need to make sure the re-numbering code is triggered by the adding or removing a data provider.
The add function is handled by the AddDataProvider class though a function called addServerButtonActionPerformed. The code to remove a data provider is in the DataProviderManager class in a function called: removeDataProvider.
Both end with this call:
eventBus.post(new DataProviderServiceChangeEvent());
I don't know how this DataProviderServiceChangeEvent object works, but I think it might be helpful. If this is meant to signal that the set of data providers has changed, then we need to find whatever code it triggers and make sure our sort and re-number code in triggered by it. Something like that would be cleaner than adding code to each function to call the sort function.