import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.concurrent.CompletableFuture;
import javax.swing.BorderFactory;
import javax.swing.Box;
private final ArrayList<String> urls = new ArrayList<>();
- private final ArrayList<Integer> statuses = new ArrayList<>();
+ private final Map<String, Integer> statuses = new HashMap<>();
private final AbstractTableModel urlTableModel = new AbstractTableModel()
{
case 0:
return urls.get(rowIndex);
case 1:
- return statuses.get(rowIndex);
+ return statuses.getOrDefault(urls.get(rowIndex), WSDiscovererI.STATUS_UNKNOWN);
default:
throw new NoSuchElementException();
}
{
String input = (String) JvOptionPane
.showInternalInputDialog(
- this,
+ this,
MessageManager.getString("label.url:"),
UIManager.getString("OptionPane.inputDialogTitle", MessageManager.getLocale()),
JOptionPane.QUESTION_MESSAGE,
if (input != null)
{
urls.add(input);
- statuses.add(discoverer.getServerStatusFor(input));
+ reloadStatusForUrl(input);
urlTableModel.fireTableRowsInserted(urls.size(), urls.size());
discoverer.setServiceUrls(urls);
}
if (input != null)
{
urls.set(i, input);
- statuses.set(i, discoverer.getServerStatusFor(input));
+ statuses.remove(input);
+ reloadStatusForUrl(input);
urlTableModel.fireTableRowsUpdated(i, i);
discoverer.setServiceUrls(urls);
}
String url = urls.get(fromIndex);
int status = statuses.get(fromIndex);
urls.set(fromIndex, urls.get(toIndex));
- statuses.set(fromIndex, statuses.get(toIndex));
urls.set(toIndex, url);
- statuses.set(toIndex, status);
if (urlListTable.getSelectedRow() == fromIndex)
{
urlListTable.setRowSelectionInterval(toIndex, toIndex);
urls.addAll(discoverer.getServiceUrls());
for (String url : urls)
{
- statuses.add(discoverer.getServerStatusFor(url));
+ reloadStatusForUrl(url);
}
urlTableModel.fireTableDataChanged();
};
urls.addAll(discoverer.getServiceUrls());
for (String url : urls)
{
- statuses.add(discoverer.getServerStatusFor(url));
+ reloadStatusForUrl(url);
}
}
+
+ private void reloadStatusForUrl(String url)
+ {
+ CompletableFuture.supplyAsync(() -> discoverer.getServerStatusFor(url))
+ .thenAccept((status) -> {
+ statuses.put(url, status);
+ int row = urls.indexOf(url);
+ if (row >= 0)
+ urlTableModel.fireTableCellUpdated(row, 1);
+ });
+ }
}