2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
22 package jalview.fts.core;
24 import jalview.fts.api.FTSData;
25 import jalview.fts.api.FTSDataColumnI;
27 import java.util.Collection;
29 import javax.swing.JTable;
30 import javax.swing.table.DefaultTableModel;
33 * Represents the response model generated by the FTSRestClient upon successful
34 * execution of a given FTS request
39 public class FTSRestResponse
41 private int numberOfItemsFound;
43 private String responseTime;
45 private Collection<FTSData> searchSummary;
47 public int getNumberOfItemsFound()
49 return numberOfItemsFound;
52 public void setNumberOfItemsFound(int itemFound)
54 this.numberOfItemsFound = itemFound;
57 public String getResponseTime()
62 public void setResponseTime(String responseTime)
64 this.responseTime = responseTime;
67 public Collection<FTSData> getSearchSummary()
72 public void setSearchSummary(Collection<FTSData> searchSummary)
74 this.searchSummary = searchSummary;
78 * Convenience method to obtain a Table model for a given summary List based
79 * on the request parameters
82 * the FTSRestRequest object which holds useful information for
83 * creating a table model
84 * @param summariesList
85 * the summary list which contains the data for populating the
87 * @return the table model which was dynamically generated
89 public static DefaultTableModel getTableModel(FTSRestRequest request,
90 Collection<FTSData> summariesList)
92 final FTSDataColumnI[] cols = request.getWantedFields()
93 .toArray(new FTSDataColumnI[0]);
94 final int colOffset = request.getAssociatedSequence() == null ? 0 : 1;
95 DefaultTableModel tableModel = new DefaultTableModel()
98 public boolean isCellEditable(int row, int column)
104 public Class<?> getColumnClass(int columnIndex)
106 if (colOffset == 1 && columnIndex == 0)
110 return cols[columnIndex - colOffset].getDataColumnClass();
114 if (request.getAssociatedSequence() != null)
116 tableModel.addColumn("Ref Sequence"); // Create sequence column header if
117 // exists in the request
119 for (FTSDataColumnI field : request
122 tableModel.addColumn(field.getName()); // Create sequence column header if
123 // exists in the request
126 for (FTSData res : summariesList)
128 tableModel.addRow(res.getSummaryData()); // Populate table rows with
135 public static void configureTableColumn(JTable tbl_summary,
136 Collection<FTSDataColumnI> wantedFields)
140 // wait for table model initialisation to complete
142 } catch (InterruptedException e1)
144 e1.printStackTrace();
146 for (FTSDataColumnI wantedField : wantedFields)
150 tbl_summary.getColumn(wantedField.getName()).setMinWidth(
151 wantedField.getMinWidth());
152 tbl_summary.getColumn(wantedField.getName()).setMaxWidth(
153 wantedField.getMaxWidth());
154 tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(
155 wantedField.getPreferredWidth());
156 } catch (Exception e)