X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FWsPreferences.java;h=6be5d44ee66e0b5e8978d0996acb5b59489af4b3;hb=c3583f7ab67ddb450f61af4d36af839ddf485a09;hp=7104fa9a9bf485d248eca4eb6c6661a3df82b8d2;hpb=20c48abe18f05c2802d7e59e1efb227547a4165d;p=jalview.git diff --git a/src/jalview/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java index 7104fa9..6be5d44 100644 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@ -1,13 +1,13 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) + * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -42,7 +42,6 @@ import javax.swing.table.TableCellRenderer; public class WsPreferences extends GWsPreferences { - public WsPreferences() { super(); @@ -110,73 +109,81 @@ public class WsPreferences extends GWsPreferences }; - private void updateList() { + private void updateList() + { Object tdat[][] = new Object[wsUrls.size()][2]; - int r=0; + int r = 0; for (String url : wsUrls) { int status = Jws2Discoverer.getDiscoverer().getServerStatusFor(url); - tdat[r][1]=new Integer(status); - tdat[r++][0]=url; + tdat[r][1] = new Integer(status); + tdat[r++][0] = url; } - + wsList.setModel(new WsUrlTableModel(tdat)); wsList.getColumn("Status").setMinWidth(10); } - private class JabaWSStatusRenderer extends JPanel implements TableCellRenderer + + private class JabaWSStatusRenderer extends JPanel implements + TableCellRenderer { public JabaWSStatusRenderer() { setOpaque(true); - setMinimumSize(new Dimension(10,10)); -// setText(" "); - + setMinimumSize(new Dimension(10, 10)); + // setText(" "); + } + /** * render an Integer reflecting service status as a colour and symbol */ @Override public Component getTableCellRendererComponent(JTable arg0, - Object status, boolean isSelected, boolean hasFocus, int row, int column) + Object status, boolean isSelected, boolean hasFocus, int row, + int column) { Color c; - String t=new String(""); + String t = new String(""); switch (((Integer) status).intValue()) { case 1: -// cb.setSelected(true); - //cb.setBackground( - c=Color.green; + // cb.setSelected(true); + // cb.setBackground( + c = Color.green; break; case 0: -// cb.setSelected(true); -// cb.setBackground( - c=Color.lightGray; + // cb.setSelected(true); + // cb.setBackground( + c = Color.lightGray; break; case -1: - //cb.setSelected(false); - //cb.setBackground( - c=Color.red; + // cb.setSelected(false); + // cb.setBackground( + c = Color.red; break; default: - //cb.setSelected(false); - //cb.setBackground( - c=Color.orange; + // cb.setSelected(false); + // cb.setBackground( + c = Color.orange; } setBackground(c); - //setText(t); + // setText(t); return this; - + } } - private class WsUrlTableModel extends AbstractTableModel { - + + private class WsUrlTableModel extends AbstractTableModel + { + private Object[][] data; + public WsUrlTableModel(Object[][] tdat) { - this.data=tdat; + this.data = tdat; } @Override @@ -184,35 +191,41 @@ public class WsPreferences extends GWsPreferences { return 2; } + @Override public String getColumnName(int column) { - if (column==1) + if (column == 1) { return "Status"; } return "Service URL"; } + @Override public int getRowCount() { - if (data==null) + if (data == null) { return 0; } return data.length; } + @Override - public java.lang.Class getColumnClass(int columnIndex) { + public java.lang.Class getColumnClass(int columnIndex) + { return getValueAt(0, columnIndex).getClass(); }; + @Override public Object getValueAt(int rowIndex, int columnIndex) { return data[rowIndex][columnIndex]; } - + } + private void updateRsbsList() { sbrsList.setListData(rsbsUrls); @@ -394,7 +407,7 @@ public class WsPreferences extends GWsPreferences wsUrls.setElementAt(wsUrls.elementAt(p), p + 1); wsUrls.setElementAt(t, p); updateList(); - wsList.getSelectionModel().setSelectionInterval(p+1,p + 1); + wsList.getSelectionModel().setSelectionInterval(p + 1, p + 1); update++; } } @@ -416,7 +429,7 @@ public class WsPreferences extends GWsPreferences wsUrls.setElementAt(wsUrls.elementAt(p), p - 1); wsUrls.setElementAt(t, p); updateList(); - wsList.getSelectionModel().setSelectionInterval(p-1,p - 1); + wsList.getSelectionModel().setSelectionInterval(p - 1, p - 1); update++; } }