From: jprocter Date: Tue, 30 Aug 2011 13:02:46 +0000 (+0100) Subject: JAL-715 rsbs service editing X-Git-Tag: Release_2_7~65 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=11f9bc4d774182d8868d97cc4810a23c861ed82d;p=jalview.git JAL-715 rsbs service editing --- diff --git a/src/jalview/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java index b88f27e..5258a4c 100644 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@ -31,6 +31,7 @@ import javax.swing.JTextField; import jalview.bin.Cache; import jalview.jbgui.GWsPreferences; +import jalview.ws.rest.RestServiceDescription; public class WsPreferences extends GWsPreferences { @@ -41,7 +42,7 @@ public class WsPreferences extends GWsPreferences initFromPreferences(); } - Vector wsUrls, oldUrls; + Vector wsUrls, oldUrls,rsbsUrls,oldRsbsUrls; private boolean needWsMenuUpdate; @@ -62,6 +63,17 @@ public class WsPreferences extends GWsPreferences wsUrls = new Vector(); } updateList(); + rsbsUrls = jalview.ws.rest.RestClient.getRsbsDescriptions(); + if (rsbsUrls != null) + { + oldRsbsUrls = new Vector(rsbsUrls); + } + else + { + oldRsbsUrls = null; + rsbsUrls = new Vector(); + } + updateRsbsList(); enableEnfinServices.setSelected(oldEnfin = Cache.getDefault( "SHOW_ENFIN_SERVICES", true)); enableEnfinServices.addActionListener(updateAction); @@ -97,11 +109,21 @@ public class WsPreferences extends GWsPreferences wsList.setListData(wsUrls); } + private void updateRsbsList() + { + sbrsList.setListData(rsbsUrls); + } + private void updateServiceList() { jalview.ws.jws2.Jws2Discoverer.setServiceUrls(wsUrls); } + private void updateRsbsServiceList() + { + jalview.ws.rest.RestClient.setRsbsServices(rsbsUrls); + } + /* * (non-Javadoc) * @@ -133,7 +155,7 @@ public class WsPreferences extends GWsPreferences int sel = wsList.getSelectedIndex(); if (sel > -1) { - String url = editUrl(wsUrls.elementAt(sel), "Edit JWS2 URL"); + String url = editUrl(wsUrls.elementAt(sel), "Edit JABAWS URL"); if (url != null) { int present = wsUrls.indexOf(url); @@ -154,7 +176,46 @@ public class WsPreferences extends GWsPreferences } } } - + @Override + protected void newSbrsUrl_actionPerformed(ActionEvent e) + { + RestServiceEditorPane rse = new RestServiceEditorPane(); + rse.showDialog("Add a new Simple Bioinformatics Rest Service"); + String rservice = rse.getEditedRestService(); + if (rservice!=null && !rsbsUrls.contains(rservice)) + { + rsbsUrls.add(rservice); + update++; + updateRsbsList(); + } + } + @Override + protected void editSbrsUrl_actionPerformed(ActionEvent e) + { + int sel = sbrsList.getSelectedIndex(); + if (sel > -1) + { + RestServiceEditorPane rse = new RestServiceEditorPane(new RestServiceDescription(rsbsUrls.elementAt(sel))); + rse.showDialog("Edit Simple Bioinformatics Rest Service entry"); + String rservice = rse.getEditedRestService(); + if (rservice!=null) + { + int present = rsbsUrls.indexOf(rservice); + if (present==-1) { + update++; + rsbsUrls.setElementAt(rservice,sel); + updateRsbsList(); + } else { + if (present!=sel) { + rsbsUrls.removeElementAt(sel); + update++; + updateRsbsList(); + } + } + } + } + } + void updateWsMenuConfig(boolean old) { if (old) @@ -164,6 +225,11 @@ public class WsPreferences extends GWsPreferences update++; } wsUrls = (oldUrls == null) ? null : new Vector(oldUrls); + if (oldRsbsUrls!=rsbsUrls || (rsbsUrls!=null && oldRsbsUrls!=null && !oldRsbsUrls.equals(rsbsUrls))) + { + update++; + } + oldRsbsUrls = (oldRsbsUrls == null) ? null : new Vector(oldRsbsUrls); } else { @@ -190,9 +256,11 @@ public class WsPreferences extends GWsPreferences "WSMENU_BYTYPE", Boolean.valueOf(old ? oldIndexByType : indexByType.isSelected()) .toString()); + Cache.setProperty("SHOW_WSDISCOVERY_ERRORS", Boolean.valueOf(old ? oldWsWarning : displayWsWarning.isSelected()).toString()); updateServiceList(); + updateRsbsServiceList(); } /* @@ -213,6 +281,7 @@ public class WsPreferences extends GWsPreferences wsUrls.setElementAt(t, p); updateList(); wsList.setSelectedIndex(p + 1); + update++; } } @@ -234,6 +303,7 @@ public class WsPreferences extends GWsPreferences wsUrls.setElementAt(t, p); updateList(); wsList.setSelectedIndex(p - 1); + update++; } } @@ -316,7 +386,7 @@ public class WsPreferences extends GWsPreferences @Override protected void newWsUrl_actionPerformed(ActionEvent e) { - String url = editUrl(null, "Add new JWS2 URL"); + String url = editUrl(null, "Add new JABAWS URL"); if (url != null) { if (!wsUrls.contains(url))