X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fuimodel%2FPDBRestResponse.java;h=bbd5e8437c7cef0ba346efed569e25cdc0e8e3e3;hb=053c5f25f135f0eeeb60acad625b246dc66e75fc;hp=fb227ee17bbd603f17c7a70971723e74f7a7d17b;hpb=49207bb4d5c7b380978923817742d095b3f685b3;p=jalview.git diff --git a/src/jalview/ws/uimodel/PDBRestResponse.java b/src/jalview/ws/uimodel/PDBRestResponse.java index fb227ee..bbd5e84 100644 --- a/src/jalview/ws/uimodel/PDBRestResponse.java +++ b/src/jalview/ws/uimodel/PDBRestResponse.java @@ -21,6 +21,7 @@ package jalview.ws.uimodel; +import jalview.datamodel.SequenceI; import jalview.ws.dbsources.PDBRestClient.PDBDocField; import java.util.Collection; @@ -75,10 +76,9 @@ public class PDBRestResponse this.searchSummary = searchSummary; } - /** - * Convenience method to obtain a Table model for a given summary List and - * request + * Convenience method to obtain a Table model for a given summary List based + * on the request parameters * * @param request * the PDBRestRequest object which holds useful information for @@ -91,12 +91,18 @@ public class PDBRestResponse public static DefaultTableModel getTableModel(PDBRestRequest request, Collection summariesList) { - DefaultTableModel tableModel = new DefaultTableModel(); - + DefaultTableModel tableModel = new DefaultTableModel() + { + @Override + public boolean isCellEditable(int row, int column) + { + return false; + } + }; if (request.getAssociatedSequence() != null) { - tableModel.addColumn("Sequence"); // Create sequence column header if - // exists in the request + tableModel.addColumn("Ref Sequence"); // Create sequence column header if + // exists in the request } for (PDBDocField field : request.getWantedFields()) { @@ -109,44 +115,41 @@ public class PDBRestResponse tableModel.addRow(res.getSummaryData()); // Populate table rows with // summary list } + return tableModel; } /** * Model for a unique response summary * - * @author tcnofoegbu - * */ public class PDBResponseSummary { private String pdbId; - private String[] summaryRowData; + private Object[] summaryRowData; - private String associatedSequence; + private SequenceI associatedSequence; - public PDBResponseSummary(JSONObject doc, PDBRestRequest request) + public PDBResponseSummary(JSONObject pdbJsonDoc, PDBRestRequest request) { Collection diplayFields = request.getWantedFields(); - String associatedSeq = request.getAssociatedSequence(); + SequenceI associatedSeq = request.getAssociatedSequence(); int colCounter = 0; - summaryRowData = new String[(associatedSeq != null) ? diplayFields + summaryRowData = new Object[(associatedSeq != null) ? diplayFields .size() + 1 : diplayFields.size()]; if (associatedSeq != null) { - this.associatedSequence = (associatedSeq.length() > 18) ? associatedSeq - .substring(0, 18) : associatedSeq; + this.associatedSequence = associatedSeq; summaryRowData[0] = associatedSequence; colCounter = 1; } for (PDBDocField field : diplayFields) { - String fieldData = (doc.get(field.getCode()) == null) ? "" : doc - .get(field.getCode()).toString(); - if (field.equals(PDBDocField.PDB_ID) - && doc.get(PDBDocField.PDB_ID.getCode()) != null) + String fieldData = (pdbJsonDoc.get(field.getCode()) == null) ? "" + : pdbJsonDoc.get(field.getCode()).toString(); + if (field.equals(PDBDocField.PDB_ID)) { this.pdbId = fieldData; summaryRowData[colCounter++] = this.pdbId; @@ -168,7 +171,7 @@ public class PDBRestResponse this.pdbId = pdbId; } - public String[] getSummaryData() + public Object[] getSummaryData() { return summaryRowData; } @@ -178,23 +181,32 @@ public class PDBRestResponse this.summaryRowData = summaryData; } + /** + * Returns a string representation of this object; + */ @Override public String toString() { StringBuilder summaryFieldValues = new StringBuilder(); - for (String summaryField : summaryRowData) + for (Object summaryField : summaryRowData) { - summaryFieldValues.append(summaryField).append("\t"); + summaryFieldValues.append(summaryField.toString()).append("\t"); } return summaryFieldValues.toString(); } + /** + * Returns hash code value for this object + */ @Override public int hashCode() { return Objects.hash(this.pdbId, this.toString()); } + /** + * Indicates whether some object is equal to this one + */ @Override public boolean equals(Object that) { @@ -209,4 +221,3 @@ public class PDBRestResponse } } -