label.structure_chooser = Structure Chooser
label.select = Select :
label.invert = Invert
-label.select_pdb_file = Select PDB File
\ No newline at end of file
+label.select_pdb_file = Select PDB File
+info.select_filter_option = Select Filter Option/Manual Entry
+info.associate_wit_sequence = Associate with Sequence
\ No newline at end of file
import java.util.List;
import javax.swing.DefaultListModel;
-import javax.swing.SwingUtilities;
@SuppressWarnings("serial")
public class PDBSearchPanel extends GPDBSearchPanel
.getProgressIndicator();
}
- public static void main(String[] args)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- new PDBSearchPanel(null);
- }
- });
- }
@Override
public void txt_search_ActionPerformed()
if (txt_search.getText().trim().length() > 0)
{
long startTime = System.currentTimeMillis();
- PDBRestClient pdbRestCleint = new PDBRestClient();
+
String searchTarget = ((PDBDocField) cmb_searchTarget
.getSelectedItem()).getCode();
- PDBRestRequest request = new PDBRestRequest();
- request.setAllowEmptySeq(allowEmptySequence);
- request.setResponseSize(100);
- request.setFieldToSearchBy(searchTarget + ":");
- request.setSearchTerm(txt_search.getText());
List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
wantedFields.add(PDBDocField.MOLECULE_TYPE);
wantedFields.add(PDBDocField.PDB_ID);
wantedFields.add(PDBDocField.TITLE);
// wantedFields.add(PDBDocField.RESOLUTION);
// wantedFields.add(PDBDocField.EXPERIMENTAL_METHOD);
+
+ PDBRestRequest request = new PDBRestRequest();
+ request.setAllowEmptySeq(allowEmptySequence);
+ request.setResponseSize(100);
+ request.setFieldToSearchBy(searchTarget + ":");
+ request.setSearchTerm(txt_search.getText());
request.setWantedFields(wantedFields);
+
+ PDBRestClient pdbRestCleint = new PDBRestClient();
PDBRestResponse resultList = pdbRestCleint.executeRequest(request);
if (resultList.getSearchSummary() != null)
{
mainFrame.dispose();
}
+ /**
+ * Add the discovered/selected sequences to a target alignment window
+ */
public void loadSelectedPDBSequencesToAlignment()
{
mainFrame.dispose();
worker.start();
}
+ /**
+ * Populates search target combo-box options
+ */
public void populateCmbSearchTargetOptions()
{
List<PDBDocField> searchableTargets = new ArrayList<PDBDocField>();
import java.util.Vector;
import javax.swing.JCheckBox;
-import javax.swing.JOptionPane;
+import javax.swing.JComboBox;
import javax.swing.ListSelectionModel;
/**
private PDBRestClient pdbRestCleint;
+ private String selectedPdbFileName;
+
+ private boolean isValidPBDEntry;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
if (discoveredStructuresSet != null
&& !discoveredStructuresSet.isEmpty())
{
- jList_FoundStructures.setModel(PDBRestResponse
- .getListModel(discoveredStructuresSet));
tbl_summary.setModel(PDBRestResponse.getTableModel(pdbRequest,
discoveredStructuresSet));
- // resizeColumnWidth(summaryTable);
structuresDiscovered = true;
noOfStructuresFound = discoveredStructuresSet.size();
}
int endIndex = queryBuilder.lastIndexOf(" OR ");
query = queryBuilder.toString().substring(5, endIndex);
}
- // System.out.println("Query -----> " + query);
return query;
}
@Override
public void run()
{
+ long startTime = System.currentTimeMillis();
try
{
lbl_loading.setVisible(true);
List<PDBResponseSummary> originalDiscoveredStructuresList = new ArrayList<PDBResponseSummary>(
discoveredStructuresSet);
originalDiscoveredStructuresList.removeAll(filteredResponse);
-
Collection<PDBResponseSummary> reorderedStructuresSet = new ArrayList<PDBResponseSummary>();
reorderedStructuresSet.addAll(filteredResponse);
reorderedStructuresSet.addAll(originalDiscoveredStructuresList);
- jList_FoundStructures.setModel(PDBRestResponse
- .getListModel(reorderedStructuresSet));
tbl_summary.setModel(PDBRestResponse.getTableModel(pdbRequest,
reorderedStructuresSet));
- // int[] filterIndice = new int[filterResponseCount];
ListSelectionModel model = tbl_summary.getSelectionModel();
model.clearSelection();
for (int x = 0; x < filterResponseCount; x++)
{
- // filterIndice[x] = x;
model.addSelectionInterval(x, x);
}
// collection
originalDiscoveredStructuresList = null;
reorderedStructuresSet = null;
-
- // jListFoundStructures.setSelectedIndices(filterIndice);
}
lbl_loading.setVisible(false);
{
e.printStackTrace();
}
+ String totalTime = (System.currentTimeMillis() - startTime)
+ + " milli secs";
+ mainFrame.setTitle("Structure Chooser - Filter time (" + totalTime
+ + ")");
+
+ validateSelections();
}
});
filterThread.start();
int value = chooser.showOpenDialog(null);
if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
{
- String choice = chooser.getSelectedFile().getPath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
- new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
- jalview.io.AppletFormatAdapter.FILE, selectedSequence, true,
- Desktop.instance);
- }
- }
-
- /**
- * Handles action event for btn_ok
- */
- @Override
- public void ok_ActionPerformed()
- {
- int pdbIdCol = getPDBIdColumIndex(pdbRequest.getWantedFields());
- int[] selectedRows = tbl_summary.getSelectedRows();
- PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
- int count = 0;
- for (int summaryRow : selectedRows)
- {
- String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol)
- .toString();
- PDBEntry pdbEntry = new PDBEntry();
- pdbEntry.setId(pdbIdStr);
- pdbEntry.setType("PDB");
- pdbEntriesToView[count++] = pdbEntry;
- }
- new StructureViewer(ap.getStructureSelectionManager()).viewStructures(
- ap, pdbEntriesToView, ap.av.collateForPDB(pdbEntriesToView));
- }
-
- /**
- * Handles action event for manual entry of pdb ids
- */
- public void enterPDB_actionPerformed()
- {
- String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
- MessageManager.getString("label.enter_pdb_id"),
- MessageManager.getString("label.enter_pdb_id"),
- JOptionPane.QUESTION_MESSAGE);
- if (id != null && id.length() > 0)
- {
- PDBEntry entry = new PDBEntry();
- entry.setId(id.toUpperCase());
- selectedSequence.getDatasetSequence().addPDBId(entry);
+ selectedPdbFileName = chooser.getSelectedFile().getPath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
+ validateSelections();
}
}
*/
protected void updateCurrentView()
{
- FilterOption selectedOption = ((FilterOption) cmb_filterOption
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
layout_switchableViews.show(pnl_switchableViews,
- selectedOption.getView());
- chk_invertFilter.setEnabled(false);
- if (selectedOption.getView() == VIEWS_FILTER)
+ selectedFilterOpt.getView());
+ String filterTitle = mainFrame.getTitle();
+ mainFrame.setTitle(frameTitle);
+ chk_invertFilter.setVisible(false);
+ if (selectedFilterOpt.getView() == VIEWS_FILTER)
{
- chk_invertFilter.setEnabled(true);
- filterResultSet(selectedOption.getValue());
+ mainFrame.setTitle(filterTitle);
+ chk_invertFilter.setVisible(true);
+ filterResultSet(selectedFilterOpt.getValue());
}
+ else
+ {
+ idInputAssSeqPanel.loadCmbAssSeq();
+ fileChooserAssSeqPanel.loadCmbAssSeq();
+ }
+ validateSelections();
+ }
+
+ /**
+ * Validates user selection and activates the view button if all parameters
+ * are correct
+ */
+ public void validateSelections()
+ {
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ btn_view.setEnabled(false);
+ String currentView = selectedFilterOpt.getView();
+ if (currentView == VIEWS_FILTER)
+ {
+ if (tbl_summary.getSelectedRows().length > 0)
+ {
+ btn_view.setEnabled(true);
+ }
+ }
+ else if (currentView == VIEWS_ENTER_ID)
+ {
+ validateAssociationEnterPdb();
+ }
+ else if (currentView == VIEWS_FROM_FILE)
+ {
+ validateAssociationFromFile();
+ }
+
+ }
+
+ /**
+ * Validates inputs from the Manual PDB entry panel
+ */
+ public void validateAssociationEnterPdb()
+ {
+ AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
+ .getCmb_assSeq().getSelectedItem();
+ lbl_pdbManualFetchStatus.setIcon(errorImage);
+ if (selectedSequences.length == 1
+ || !assSeqOpt.getName().equalsIgnoreCase(
+ "-Select Associated Seq-"))
+ {
+ txt_search.setEnabled(true);
+ if (isValidPBDEntry)
+ {
+ btn_view.setEnabled(true);
+ lbl_pdbManualFetchStatus.setIcon(goodImage);
+ }
+ }
+ else
+ {
+ txt_search.setEnabled(false);
+ lbl_pdbManualFetchStatus.setIcon(errorImage);
+ }
+ }
+
+ /**
+ * Validates inputs for the manual PDB file selection options
+ */
+ public void validateAssociationFromFile()
+ {
+ AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
+ .getCmb_assSeq().getSelectedItem();
+ lbl_fromFileStatus.setIcon(errorImage);
+ if (selectedSequences.length == 1
+ || (assSeqOpt != null
+ && !assSeqOpt.getName().equalsIgnoreCase(
+ "-Select Associated Seq-")))
+ {
+ btn_pdbFromFile.setEnabled(true);
+ if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
+ {
+ btn_view.setEnabled(true);
+ lbl_fromFileStatus.setIcon(goodImage);
+ }
+ }
+ else
+ {
+ btn_pdbFromFile.setEnabled(false);
+ lbl_fromFileStatus.setIcon(errorImage);
+ }
+ }
+
+ @Override
+ public void cmbAssSeqStateChanged()
+ {
+ validateSelections();
}
/**
}
+ /**
+ * Handles action event for btn_ok
+ */
+ @Override
+ public void ok_ActionPerformed()
+ {
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ String currentView = selectedFilterOpt.getView();
+ if (currentView == VIEWS_FILTER)
+ {
+ int pdbIdCol = getPDBIdColumIndex(pdbRequest.getWantedFields());
+ int[] selectedRows = tbl_summary.getSelectedRows();
+ PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
+ int count = 0;
+ for (int summaryRow : selectedRows)
+ {
+ String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol)
+ .toString();
+ PDBEntry pdbEntry = new PDBEntry();
+ pdbEntry.setId(pdbIdStr);
+ pdbEntry.setType("PDB");
+ pdbEntriesToView[count++] = pdbEntry;
+ }
+ new StructureViewer(ap.getStructureSelectionManager())
+ .viewStructures(ap, pdbEntriesToView,
+ ap.av.collateForPDB(pdbEntriesToView));
+ }
+ else if (currentView == VIEWS_ENTER_ID)
+ {
+ selectedSequence = ((AssociateSeqOptions) idInputAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ PDBEntry pdbEntry = new PDBEntry();
+ pdbEntry.setId(txt_search.getText());
+ pdbEntry.setType("PDB");
+ selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
+ PDBEntry[] pdbEntriesToView = new PDBEntry[]
+ { pdbEntry };
+ new StructureViewer(ap.getStructureSelectionManager())
+ .viewStructures(ap, pdbEntriesToView,
+ ap.av.collateForPDB(pdbEntriesToView));
+ }
+ else if (currentView == VIEWS_FROM_FILE)
+ {
+ selectedSequence = ((AssociateSeqOptions) fileChooserAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ new AssociatePdbFileWithSeq().associatePdbWithSeq(
+ selectedPdbFileName, jalview.io.AppletFormatAdapter.FILE,
+ selectedSequence, true, Desktop.instance);
+ }
+ mainFrame.dispose();
+ }
+
+ /**
+ * Populates the combo-box used in associating manually fetched structures to
+ * a unique sequence when more than one sequence selection is made.
+ */
+ public void populateCmbAssociateSeqOptions(
+ JComboBox<AssociateSeqOptions> cmb_assSeq)
+ {
+ cmb_assSeq.removeAllItems();
+ cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
+ null));
+ // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
+ if (selectedSequences.length > 1)
+ {
+ for (SequenceI seq : selectedSequences)
+ {
+ cmb_assSeq.addItem(new AssociateSeqOptions(seq));
+ }
+ }
+ else
+ {
+ cmb_assSeq.setVisible(false);
+ }
+ }
public boolean isStructuresDiscovered()
{
{
return discoveredStructuresSet;
}
+
+ @Override
+ protected void txt_search_ActionPerformed()
+ {
+ isValidPBDEntry = false;
+ if (txt_search.getText().length() > 0)
+ {
+ List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+ wantedFields.add(PDBDocField.PDB_ID);
+ pdbRequest = new PDBRestRequest();
+ pdbRequest.setAllowEmptySeq(false);
+ pdbRequest.setResponseSize(1);
+ pdbRequest.setFieldToSearchBy("(pdb_id:");
+ pdbRequest.setWantedFields(wantedFields);
+ pdbRequest.setSearchTerm(txt_search.getText() + ")");
+ pdbRequest.setAssociatedSequence(selectedSequence.getName());
+ pdbRestCleint = new PDBRestClient();
+ PDBRestResponse resultList = pdbRestCleint.executeRequest(pdbRequest);
+ if (resultList.getSearchSummary() != null
+ && resultList.getSearchSummary().size() > 0)
+ {
+ isValidPBDEntry = true;
+ }
+ }
+ validateSelections();
+ }
+
}
Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
}
+ public JComboBox<PDBDocField> getCmbSearchTarget()
+ {
+ return cmb_searchTarget;
+ }
+
+ public JTextField getTxtSearch()
+ {
+ return txt_search;
+ }
+
+ public JInternalFrame getMainFrame()
+ {
+ return mainFrame;
+ }
+
public abstract void txt_search_ActionPerformed();
public abstract void btn_ok_ActionPerformed();
public abstract void btn_cancel_ActionPerformed();
- protected abstract void populateCmbSearchTargetOptions();
+ public abstract void populateCmbSearchTargetOptions();
}
package jalview.jbgui;
+import jalview.datamodel.SequenceI;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.util.MessageManager;
-import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
-import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
-import javax.swing.ListSelectionModel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
@SuppressWarnings("serial")
/**
protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<FilterOption>();
+
protected AlignmentPanel ap;
protected JLabel lbl_result = new JLabel(
- MessageManager.getString("label.select") /* "Select : " */);
+ MessageManager.getString("label.select"));
- protected JButton btn_ok = new JButton();
+ protected JButton btn_view = new JButton();
protected JButton btn_cancel = new JButton();
protected JButton btn_pdbFromFile = new JButton();
- protected JTextField txt_search = new JTextField(18);
+ protected JTextField txt_search = new JTextField(14);
private JPanel pnl_actions = new JPanel();
private JPanel pnl_filter = new JPanel();
- private JPanel pnl_idInput = new JPanel();
+ private JPanel pnl_idInput = new JPanel(new FlowLayout());
+
+ private JPanel pnl_fileChooser = new JPanel(new FlowLayout());
+
+ private JPanel pnl_idInputBL = new JPanel(new BorderLayout());
- private JPanel pnl_fileChooser = new JPanel();
+ private JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
protected ImageIcon loadingImage = new ImageIcon(getClass().getResource(
"/images/loading.gif"));
+ protected ImageIcon goodImage = new ImageIcon(getClass().getResource(
+ "/images/good.png"));
+
+ protected ImageIcon errorImage = new ImageIcon(getClass().getResource(
+ "/images/error.png"));
+
protected JLabel lbl_loading = new JLabel(loadingImage);
+ protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
+
+ protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
+
+ protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel();
+
+ protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel();
+
protected static final String VIEWS_FILTER = "VIEWS_FILTER";
protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
- protected JList<PDBResponseSummary> jList_FoundStructures = new JList<PDBResponseSummary>();
+ // protected JList<PDBResponseSummary> jList_FoundStructures = new
+ // JList<PDBResponseSummary>();
protected JTable tbl_summary = new JTable();
*/
private void jbInit() throws Exception
{
- btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
- btn_ok.setText(MessageManager.getString("action.view"));
- btn_ok.addActionListener(new java.awt.event.ActionListener()
+ btn_view.setFont(new java.awt.Font("Verdana", 0, 12));
+ btn_view.setText(MessageManager.getString("action.view"));
+ btn_view.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
btn_pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12));
String btn_title = MessageManager.getString("label.select_pdb_file");
- btn_pdbFromFile.setText(" " + btn_title + " ");
+ btn_pdbFromFile.setText(btn_title + " ");
btn_pdbFromFile.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
}
});
- jList_FoundStructures
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- jList_FoundStructures.setLayoutOrientation(JList.VERTICAL);
- jList_FoundStructures.setVisibleRowCount(-1);
scrl_foundStructures.setPreferredSize(new Dimension(500, 300));
scrl_foundStructures
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
chk_invertFilter.addItemListener(this);
pnl_actions.add(chk_rememberSettings);
- pnl_actions.add(btn_ok);
+ pnl_actions.add(btn_view);
pnl_actions.add(btn_cancel);
- pnl_filter.add(lbl_result);
+ // pnl_filter.add(lbl_result);
pnl_filter.add(cmb_filterOption);
+ pnl_filter.add(lbl_loading);
+ pnl_filter.add(chk_invertFilter);
lbl_loading.setVisible(false);
- pnl_filter.add(lbl_loading);
+ txt_search.setToolTipText(MessageManager
+ .getString("label.enter_pdb_id"));
+ cmb_filterOption.setToolTipText(MessageManager
+ .getString("info.select_filter_option"));
+ txt_search.getDocument().addDocumentListener(new DocumentListener()
+ {
+ @Override
+ public void insertUpdate(DocumentEvent e)
+ {
+ txt_search_ActionPerformed();
+ }
- pnl_filter.add(chk_invertFilter);
+ @Override
+ public void removeUpdate(DocumentEvent e)
+ {
+ txt_search_ActionPerformed();
+ }
- pnl_idInput.setLayout(new FlowLayout());
+ @Override
+ public void changedUpdate(DocumentEvent e)
+ {
+ txt_search_ActionPerformed();
+ }
+ });
pnl_idInput.add(txt_search);
+ pnl_idInput.add(lbl_pdbManualFetchStatus);
- pnl_fileChooser.setLayout(new FlowLayout());
pnl_fileChooser.add(btn_pdbFromFile);
+ pnl_fileChooser.add(lbl_fromFileStatus);
+
+ pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH);
+ pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER);
+
+ pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
+ pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
- pnl_switchableViews.add(pnl_fileChooser, VIEWS_FROM_FILE);
- pnl_switchableViews.add(pnl_idInput, VIEWS_ENTER_ID);
+ pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
+ pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID);
pnl_switchableViews.add(scrl_foundStructures, VIEWS_FILTER);
this.setLayout(mainLayout);
}
}
+ /**
+ * This inner class provides the provides the data model for associate
+ * sequence combo-box - cmb_assSeq
+ *
+ * @author tcnofoegbu
+ *
+ */
+ public class AssociateSeqOptions
+ {
+ private SequenceI sequence;
+ private String name;
+
+ public AssociateSeqOptions(SequenceI seq)
+ {
+ this.sequence = seq;
+ this.name = (seq.getName().length() >= 23) ? seq.getName().substring(
+ 0, 23) : seq.getName();
+ }
+
+ public AssociateSeqOptions(String name, SequenceI seq)
+ {
+ this.name = name;
+ this.sequence = seq;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public SequenceI getSequence()
+ {
+ return sequence;
+ }
+
+ public void setSequence(SequenceI sequence)
+ {
+ this.sequence = sequence;
+ }
+
+ }
+
+ /**
+ * This inner class holds the Layout and configuration of the panel which
+ * handles association of manually fetched structures to a unique sequence
+ * when more than one sequence selection is made
+ *
+ * @author tcnofoegbu
+ *
+ */
+ public class AssciateSeqPanel extends JPanel implements ItemListener
+ {
+ private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<AssociateSeqOptions>();
+ public AssciateSeqPanel()
+ {
+ this.setLayout(new FlowLayout());
+ this.add(cmb_assSeq);
+ cmb_assSeq.setToolTipText(MessageManager
+ .getString("info.associate_wit_sequence"));
+ cmb_assSeq.addItemListener(this);
+ }
+
+ public void loadCmbAssSeq()
+ {
+ populateCmbAssociateSeqOptions(cmb_assSeq);
+ }
+
+ public JComboBox<AssociateSeqOptions> getCmb_assSeq()
+ {
+ return cmb_assSeq;
+ }
+
+ public void setCmb_assSeq(JComboBox<AssociateSeqOptions> cmb_assSeq)
+ {
+ this.cmb_assSeq = cmb_assSeq;
+ }
+
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (e.getStateChange() == ItemEvent.SELECTED)
+ {
+ cmbAssSeqStateChanged();
+ }
+ }
+ }
+
public JComboBox<FilterOption> getCmbFilterOption()
{
return cmb_filterOption;
protected abstract void updateCurrentView();
- protected abstract void ok_ActionPerformed();
-
protected abstract void populateFilterComboBox();
+ protected abstract void ok_ActionPerformed();
+
protected abstract void pdbFromFile_actionPerformed();
+
+ protected abstract void txt_search_ActionPerformed();
+
+ public abstract void populateCmbAssociateSeqOptions(
+ JComboBox<AssociateSeqOptions> cmb_assSeq);
+
+ public abstract void cmbAssSeqStateChanged();
}
package jalview.gui;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JTextField;
import org.junit.After;
import org.junit.Before;
}
@Test
- public void test()
+ public void populateCmbSearchTargetOptionsTest()
{
- fail("Not yet implemented");
+ PDBSearchPanel searchPanel = new PDBSearchPanel(null);
+ assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
+ searchPanel.populateCmbSearchTargetOptions();
}
+ @Test
+ public void txt_search_ActionPerformedTest()
+ {
+ PDBSearchPanel searchPanel = new PDBSearchPanel(null);
+ JInternalFrame mainFrame = searchPanel.getMainFrame();
+ JTextField txt_search = searchPanel.getTxtSearch();
+
+ assertTrue(mainFrame.getTitle().length() == 20);
+ assertTrue(mainFrame.getTitle()
+ .equalsIgnoreCase("PDB Sequence Fetcher"));
+
+ txt_search.setText("ABC");
+
+ assertTrue(mainFrame.getTitle().length() > 20);
+ assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
+ "PDB Sequence Fetcher"));
+ }
}