From: tcofoegbu Date: Mon, 27 Apr 2015 16:00:33 +0000 (+0100) Subject: JAL-1715 implemented selection validation for the new PDB Query interface X-Git-Tag: Jalview_2_9~45^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2e9f37c7818e03fc46d626f288cb6b7d03e4c2f5;p=jalview.git JAL-1715 implemented selection validation for the new PDB Query interface --- diff --git a/src/jalview/gui/PDBSearchPanel.java b/src/jalview/gui/PDBSearchPanel.java index 514406a..7762605 100644 --- a/src/jalview/gui/PDBSearchPanel.java +++ b/src/jalview/gui/PDBSearchPanel.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; import javax.swing.table.DefaultTableModel; @@ -60,6 +61,7 @@ public class PDBSearchPanel extends GPDBSearchPanel @Override public void txt_search_ActionPerformed() { + btn_ok.setEnabled(false); boolean allowEmptySequence = false; mainFrame.setTitle(MessageManager .getString("label.pdb_sequence_getcher")); @@ -165,20 +167,24 @@ public class PDBSearchPanel extends GPDBSearchPanel { mainFrame.dispose(); StringBuilder selectedIds = new StringBuilder(); + HashSet selectedIdsSet = new HashSet(); int pdbIdCol = PDBRestClient.getPDBIdColumIndex(wantedFields, false); int[] selectedRows = tbl_summary.getSelectedRows(); for (int summaryRow : selectedRows) { String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol) .toString(); - String searchTerm = txt_search.getText(); - selectedIds.append(getPDBIdwithSpecifiedChain(pdbIdStr, searchTerm)) - .append(";"); + selectedIdsSet.add(getPDBIdwithSpecifiedChain(pdbIdStr, searchTerm)); + } + + for (String selectedId : selectedIdsSet) + { + selectedIds.append(selectedId).append(";"); } String ids = selectedIds.toString(); - // System.out.println(">>>>>>>>>>>>>>>> selected Ids: " + ids); + System.out.println(">>>>>>>>>>>>>>>> selected Ids: " + ids); seqFetcher.textArea.setText(ids); Thread worker = new Thread(seqFetcher); worker.start(); diff --git a/src/jalview/jbgui/GPDBSearchPanel.java b/src/jalview/jbgui/GPDBSearchPanel.java index 29a0014..e74f0ef 100644 --- a/src/jalview/jbgui/GPDBSearchPanel.java +++ b/src/jalview/jbgui/GPDBSearchPanel.java @@ -30,6 +30,8 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JComboBox; @@ -108,6 +110,21 @@ tbl_summary); private void jbInit() throws Exception { tbl_summary.setAutoCreateRowSorter(true); + tbl_summary.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + if (tbl_summary.getSelectedRows().length > 0) + { + btn_ok.setEnabled(true); + } + else + { + btn_ok.setEnabled(false); + } + } + }); + btn_back.setFont(new java.awt.Font("Verdana", 0, 12)); btn_back.setText(MessageManager.getString("action.back")); btn_back.addActionListener(new java.awt.event.ActionListener() @@ -117,6 +134,8 @@ tbl_summary); btn_back_ActionPerformed(); } }); + + btn_ok.setEnabled(false); btn_ok.setFont(new java.awt.Font("Verdana", 0, 12)); btn_ok.setText(MessageManager.getString("action.ok")); btn_ok.addActionListener(new java.awt.event.ActionListener() @@ -136,6 +155,7 @@ tbl_summary); } }); + scrl_searchResult.setPreferredSize(new Dimension(500, 300)); scrl_searchResult .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);