From a187bcd7ecb0cf1b43af64450a5e0b0d35c87027 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Fri, 15 Mar 2024 17:37:29 +0100 Subject: [PATCH] JAL-4389 Disable url editor if urls are not modifiable --- src/jalview/gui/WS2PreferencesPanel.java | 9 +++++++++ src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java | 6 ++++++ src/jalview/ws2/client/api/WebServiceDiscovererI.java | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/src/jalview/gui/WS2PreferencesPanel.java b/src/jalview/gui/WS2PreferencesPanel.java index d5dc39e..b57d75c 100644 --- a/src/jalview/gui/WS2PreferencesPanel.java +++ b/src/jalview/gui/WS2PreferencesPanel.java @@ -364,6 +364,15 @@ public class WS2PreferencesPanel extends JPanel // Initial URLs loading this.discoverer = discoverer; urls.addAll(discoverer.getUrls()); + if (!discoverer.isUrlsModifiable()) + { + urlListTable.setEnabled(false); + newWsUrl.setEnabled(false); + editWsUrl.setEnabled(false); + deleteWsUrl.setEnabled(false); + moveUrlUp.setEnabled(false); + moveUrlDown.setEnabled(false); + } for (URL url : urls) { reloadStatusForUrl(url); diff --git a/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java b/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java index 6e32d48..7539339 100644 --- a/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java +++ b/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java @@ -92,6 +92,12 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover } } + @Override + public boolean isUrlsModifiable() + { + return getUrlsPropertyKey() != null; + } + /** * Get the key in jalview property file where the urls for this discoverer are * stored. Return null if modifying urls is not supported. diff --git a/src/jalview/ws2/client/api/WebServiceDiscovererI.java b/src/jalview/ws2/client/api/WebServiceDiscovererI.java index f5a73c0..9b223eb 100644 --- a/src/jalview/ws2/client/api/WebServiceDiscovererI.java +++ b/src/jalview/ws2/client/api/WebServiceDiscovererI.java @@ -38,10 +38,18 @@ public interface WebServiceDiscovererI extends WebServiceProviderI /** * Set the list of urls where the discoverer will search for services. + * May throw UnsupportedOperationException if the list is unmodifiable. */ void setUrls(List wsUrls); /** + * Check if list of urls is modifiable. + * + * @return is list modifiable + */ + boolean isUrlsModifiable(); + + /** * Test if the url is a valid url for that discoverer. */ default boolean testUrl(URL url) -- 1.7.10.2