From 831ad693b1320d74143011e1fe510496876e148a Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 1 Mar 2012 11:05:17 +0000 Subject: [PATCH] debug local source management buttons and formatting --- src/jalview/gui/DasSourceBrowser.java | 4 +- .../dbsources/das/datamodel/DasSourceRegistry.java | 46 ++++++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 9edb8b0..40d936e 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -538,10 +538,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname)); selectedSources.remove(nickname); Object[][] data = new Object[sourceRegistry.getSources().size()][2]; - DASTableModel dtm = (table != null) ? (DASTableModel) table - .getModel() : null; int index = 0, - l = dtm.getRowCount(); + l = table.getRowCount(); for (int i = 0; i < l; i++) { diff --git a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java b/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java index cf78202..7257d0c 100644 --- a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java +++ b/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java @@ -98,7 +98,8 @@ public class DasSourceRegistry implements DasSourceRegistryI, URL url = new URL(registryURL); org.biodas.jdas.client.SourcesClientInterface client = new SourcesClient(); - SOURCES sources = client.fetchDataRegistry(registryURL, null, null, null, null, null, null); + SOURCES sources = client.fetchDataRegistry(registryURL, null, null, + null, null, null, null); List dassources = sources.getSOURCE(); ArrayList dsrc = new ArrayList(); @@ -116,7 +117,6 @@ public class DasSourceRegistry implements DasSourceRegistryI, } } - public void run() { getSources(); @@ -138,30 +138,35 @@ public class DasSourceRegistry implements DasSourceRegistryI, */ private void addLocalDasSources() { - String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE"); - if (local != null) + if (localSources == null) { - StringTokenizer st = new StringTokenizer(local, "\t"); - while (st.hasMoreTokens()) + // get local sources from properties and initialise the local source list + String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE"); + if (local != null) { - String token = st.nextToken(); - int bar = token.indexOf("|"); - String url = token.substring(bar + 1); - boolean features = true, sequence = false; - if (url.startsWith("sequence:")) + StringTokenizer st = new StringTokenizer(local, "\t"); + while (st.hasMoreTokens()) { - url = url.substring(9); - // this source also serves sequences as well as features - sequence = true; + String token = st.nextToken(); + int bar = token.indexOf("|"); + String url = token.substring(bar + 1); + boolean features = true, sequence = false; + if (url.startsWith("sequence:")) + { + url = url.substring(9); + // this source also serves sequences as well as features + sequence = true; + } + createLocalSource(url, token.substring(0, bar), sequence, + features); } - createLocalSource(url, token.substring(0, bar), sequence, features); } } } private List appendLocalSources() { - List srclist=new ArrayList(); + List srclist = new ArrayList(); addLocalDasSources(); sourceNames = new Hashtable(); if (dasSources != null) @@ -202,7 +207,7 @@ public class DasSourceRegistry implements DasSourceRegistryI, { localSources = new Hashtable(); } - jalviewSourceI src=new JalviewSource(local, true); + jalviewSourceI src = new JalviewSource(local, true); localSources.put(local.getTitle(), src); return src; } @@ -227,14 +232,14 @@ public class DasSourceRegistry implements DasSourceRegistryI, */ CAPABILITY cap = new CAPABILITY(); cap.setType("das1:" + Capabilities.SEQUENCE.getName()); - cap.setQueryUri(url+"/sequence"); + cap.setQueryUri(url + "/sequence"); cp.add(cap); } if (features) { CAPABILITY cap = new CAPABILITY(); cap.setType("das1:" + Capabilities.FEATURES.getName()); - cap.setQueryUri(url+"/features"); + cap.setQueryUri(url + "/features"); cp.add(cap); } @@ -258,6 +263,9 @@ public class DasSourceRegistry implements DasSourceRegistryI, localSources.remove(source.getTitle()); sourceNames.remove(source.getTitle()); dasSources.remove(source); + jalview.bin.Cache.setProperty("DAS_LOCAL_SOURCE", + getLocalSourceString()); + return true; } return false; -- 1.7.10.2