import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.List;
import javax.swing.ImageIcon;
protected int pageLimit;
+ protected HashSet<String> paginatorCart = new HashSet<String>();
+
private JTable tbl_summary = new JTable()
{
private boolean inLayout;
if (!getTypedText().equalsIgnoreCase(lastSearchTerm))
{
searchAction(true);
+ paginatorCart.clear();
lastSearchTerm = getTypedText();
}
}
if (wantedFieldsUpdated())
{
searchAction(true);
+ paginatorCart.clear();
}
else
{
public void validateSelection()
{
- if (tbl_summary.getSelectedRows().length > 0)
+ if (tbl_summary.getSelectedRows().length > 0
+ || !paginatorCart.isEmpty())
{
btn_ok.setEnabled(true);
}
@Override
public void prevPageAction()
{
+ updatePaginatorCart();
if (offSet >= pageLimit)
{
offSet = offSet - pageLimit;
@Override
public void nextPageAction()
{
+ updatePaginatorCart();
offSet = offSet + pageLimit;
searchAction(false);
+ }
+
+ public void updatePaginatorCart()
+ {
+ int primaryKeyColIndex = 0;
+ JTable resultTable = getResultTable();
+ int totalRows = resultTable.getRowCount();
+ try
+ {
+ primaryKeyColIndex = getFTSRestClient().getPrimaryKeyColumIndex(
+ wantedFields, false);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ for (int row = 0; row < totalRows; row++)
+ {
+ String id = (String) resultTable.getValueAt(row, primaryKeyColIndex);
+ if (paginatorCart.contains(id))
+ {
+ paginatorCart.remove(id);
+ }
+ }
+ int[] selectedRows = resultTable.getSelectedRows();
+ for (int summaryRow : selectedRows)
+ {
+ String idStr = resultTable.getValueAt(summaryRow,
+ primaryKeyColIndex).toString();
+ paginatorCart.add(idStr);
+ }
+ // System.out.println("Paginator shopping cart size : "
+ // + paginatorCart.size());
}
+ public void updateSummaryTableSelections()
+ {
+ JTable resultTable = getResultTable();
+ if (paginatorCart.isEmpty())
+ {
+ return;
+ }
+ int primaryKeyColIndex = 0;
+ try
+ {
+ primaryKeyColIndex = getFTSRestClient().getPrimaryKeyColumIndex(
+ wantedFields, false);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ // System.out.println(">>>>>> got here : 1");
+ int totalRows = resultTable.getRowCount();
+ // resultTable.clearSelection();
+ for (int row = 0; row < totalRows; row++)
+ {
+ String id = (String) resultTable.getValueAt(row, primaryKeyColIndex);
+ if (paginatorCart.contains(id))
+ {
+ resultTable.addRowSelectionInterval(row, row);
+ }
+ }
+ validateSelection();
+ }
public void refreshPaginatorState()
{
// System.out.println("resultSet count : " + resultSetCount);
long endTime = System.currentTimeMillis();
totalResultSetCount = resultList.getNumberOfItemsFound();
- resultSetCount = resultList.getSearchSummary().size();
+ resultSetCount = resultList.getSearchSummary() == null ? 0
+ : resultList.getSearchSummary().size();
String result = (resultSetCount > 0) ? MessageManager
.getString("label.results") : MessageManager
.getString("label.result");
setSearchInProgress(false);
refreshPaginatorState();
+ updateSummaryTableSelections();
}
}
}.start();
e.printStackTrace();
}
int[] selectedRows = getResultTable().getSelectedRows();
+ String searchTerm = txt_search.getText();
for (int summaryRow : selectedRows)
{
String idStr = getResultTable().getValueAt(summaryRow,
primaryKeyColIndex)
.toString();
- String searchTerm = txt_search.getText();
+ selectedIdsSet.add(getPDBIdwithSpecifiedChain(idStr, searchTerm));
+ }
+
+ for (String idStr : paginatorCart)
+ {
selectedIdsSet.add(getPDBIdwithSpecifiedChain(idStr, searchTerm));
}
throw new Exception(errorMessage);
}
+ int xTotalResults = Integer.valueOf(clientResponse.getHeaders()
+ .get("X-Total-Results").get(0));
clientResponse = null;
client = null;
return parseUniprotResponse(uniProtTabDelimittedResponseString,
- uniportRestRequest);
+ uniportRestRequest, xTotalResults);
} catch (Exception e)
{
String exceptionMsg = e.getMessage();
public FTSRestResponse parseUniprotResponse(
String uniProtTabDelimittedResponseString,
- FTSRestRequest uniprotRestRequest)
+ FTSRestRequest uniprotRestRequest, int xTotalResults)
{
FTSRestResponse searchResult = new FTSRestResponse();
List<FTSData> result = null;
// System.out.println(dataRow);
result.add(getFTSData(dataRow, uniprotRestRequest));
}
- searchResult.setNumberOfItemsFound(result.size());
+ searchResult.setNumberOfItemsFound(xTotalResults);
searchResult.setSearchSummary(result);
}
return searchResult;
}
long endTime = System.currentTimeMillis();
- resultSetCount = resultList.getNumberOfItemsFound();
+ totalResultSetCount = resultList.getNumberOfItemsFound();
+ resultSetCount = resultList.getSearchSummary() == null ? 0
+ : resultList.getSearchSummary().size();
String result = (resultSetCount > 0) ? MessageManager
.getString("label.results") : MessageManager
.getString("label.result");
{
updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
+ " " + (offSet + 1) + " to "
- + (offSet + resultSetCount)
+ + (offSet + resultSetCount) + " of "
+ + totalResultSetCount
+ " " + " (" + (endTime - startTime) + " milli secs)");
}
else
}
setSearchInProgress(false);
refreshPaginatorState();
+ updateSummaryTableSelections();
}
}
}.start();
primaryKeyColIndex).toString();
selectedIdsSet.add(idStr);
}
-
+ selectedIdsSet.addAll(paginatorCart);
for (String selectedId : selectedIdsSet)
{
selectedIds.append(selectedId).append(";");
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import javax.swing.table.TableColumn;
@SuppressWarnings("serial")
/**
protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB";
+ protected JTable tbl_local_pdb = new JTable();
+
+ protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
+
+ private JTabbedPane pnl_filter = new JTabbedPane();
+
+ private FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
+ PreferenceSource.STRUCTURE_CHOOSER,
+ PDBFTSRestClient.getInstance());
+
+ protected FTSDataColumnI[] previousWantedFields;
+
protected JTable tbl_summary = new JTable()
{
+ private boolean inLayout;
+
+ @Override
+ public boolean getScrollableTracksViewportWidth()
+ {
+ return hasExcessWidth();
+
+ }
+
+ @Override
+ public void doLayout()
+ {
+ if (hasExcessWidth())
+ {
+ autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS;
+ }
+ inLayout = true;
+ super.doLayout();
+ inLayout = false;
+ autoResizeMode = AUTO_RESIZE_OFF;
+ }
+
+ protected boolean hasExcessWidth()
+ {
+ return getPreferredSize().width < getParent().getWidth();
+ }
+
+ @Override
+ public void columnMarginChanged(ChangeEvent e)
+ {
+ if (isEditing())
+ {
+ removeEditor();
+ }
+ TableColumn resizingColumn = getTableHeader().getResizingColumn();
+ // Need to do this here, before the parent's
+ // layout manager calls getPreferredSize().
+ if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF
+ && !inLayout)
+ {
+ resizingColumn.setPreferredWidth(resizingColumn.getWidth());
+ }
+ resizeAndRepaint();
+ }
+
@Override
public String getToolTipText(MouseEvent evt)
{
protected JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
- protected JTable tbl_local_pdb = new JTable();
-
- protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
-
- private JTabbedPane pnl_filter = new JTabbedPane();
-
- private FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
- PreferenceSource.STRUCTURE_CHOOSER, PDBFTSRestClient.getInstance());
-
- protected FTSDataColumnI[] previousWantedFields;
-
public GStructureChooser()
{
try