+ /**
+ * 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 = PDBRestClient.getPDBIdColumIndex(
+ lastPdbRequest.getWantedFields(), true);
+ 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 = cachedEntryMap.get(pdbIdStr.toLowerCase());
+ if (pdbEntry == null)
+ {
+ pdbEntry = new PDBEntry();
+ pdbEntry.setId(pdbIdStr);
+ pdbEntry.setType(PDBEntry.Type.PDB);
+ }
+ pdbEntriesToView[count++] = pdbEntry;
+ }
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, selectedSequences);
+ }
+ else if(currentView == VIEWS_LOCAL_PDB){
+ int[] selectedRows = tbl_local_pdb.getSelectedRows();
+ PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
+ int count = 0;
+ for (int row : selectedRows)
+ {
+ String entryKey = tbl_local_pdb.getValueAt(row, 1).toString()
+ .toLowerCase();
+ pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
+ }
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, selectedSequences);
+ }
+ else if (currentView == VIEWS_ENTER_ID)
+ {
+ SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ if (userSelectedSeq != null)
+ {
+ selectedSequence = userSelectedSeq;
+ }
+
+ String pdbIdStr = txt_search.getText();
+ PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
+ if (pdbEntry == null)
+ {
+ pdbEntry = new PDBEntry();
+ pdbEntry.setId(txt_search.getText());
+ pdbEntry.setType(PDBEntry.Type.PDB);
+ }
+
+ selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
+ PDBEntry[] pdbEntriesToView = new PDBEntry[]
+ { pdbEntry };
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, new SequenceI[]
+ { selectedSequence });
+ }
+ else if (currentView == VIEWS_FROM_FILE)
+ {
+ SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ if (userSelectedSeq != null)
+ {
+ selectedSequence = userSelectedSeq;
+ }
+ PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq(
+ selectedPdbFileName, jalview.io.AppletFormatAdapter.FILE,
+ selectedSequence, true, Desktop.instance);
+
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ new PDBEntry[]
+ { fileEntry }, ap, new SequenceI[]
+ { selectedSequence });
+ }
+ mainFrame.dispose();
+ }
+
+ private void launchStructureViewer(StructureSelectionManager ssm,
+ PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel,
+ SequenceI[] sequences)
+ {
+ StructureViewer sViewer = new StructureViewer(ssm);
+ if (pdbEntriesToView.length > 1)
+ {
+ sViewer.viewStructures(pdbEntriesToView, alignPanel.av.collateForPDB(pdbEntriesToView),
+ alignPanel);
+ }
+ else
+ {
+ sViewer.viewStructures(pdbEntriesToView[0], sequences,
+ alignPanel);
+ }
+ }
+
+ /**
+ * 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, JLabel lbl_associateSeq)
+ {
+ cmb_assSeq.removeAllItems();
+ cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
+ null));
+ // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
+ lbl_associateSeq.setVisible(false);
+ if (selectedSequences.length > 1)
+ {
+ for (SequenceI seq : selectedSequences)
+ {
+ cmb_assSeq.addItem(new AssociateSeqOptions(seq));
+ }
+ }
+ else
+ {
+ String seqName = selectedSequence.getDisplayId(false);
+ seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
+ lbl_associateSeq.setText(seqName);
+ lbl_associateSeq.setVisible(true);
+ cmb_assSeq.setVisible(false);
+ }
+ }