+ }
+
+
+ /**
+ * Handles action event for btn_pdbFromFile
+ */
+ public void pdbFromFile_actionPerformed()
+ {
+ jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
+ chooser.setFileView(new jalview.io.JalviewFileView());
+ chooser.setDialogTitle(MessageManager.formatMessage(
+ "label.select_pdb_file_for", new String[]
+ { selectedSequence.getDisplayId(false) }));
+ chooser.setToolTipText(MessageManager.formatMessage(
+ "label.load_pdb_file_associate_with_sequence", new String[]
+ { selectedSequence.getDisplayId(false) }));
+
+ int value = chooser.showOpenDialog(null);
+ if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
+ {
+ selectedPdbFileName = chooser.getSelectedFile().getPath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
+ validateSelections();
+ }
+ }
+
+ /**
+ * Populates the filter combo-box options dynamically depending on discovered
+ * structures
+ */
+ protected void populateFilterComboBox()
+ {
+ if (isStructuresDiscovered())
+ {
+ cmb_filterOption.addItem(new FilterOption("Best Quality",
+ PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
+ cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
+ PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
+ cmb_filterOption.addItem(new FilterOption("Highest Resolution",
+ PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
+ cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
+ PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
+ cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
+ PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
+ cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
+ PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
+ }
+ cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
+ VIEWS_ENTER_ID));
+ cmb_filterOption.addItem(new FilterOption("From File", "-",
+ VIEWS_FROM_FILE));
+ cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
+ VIEWS_LOCAL_PDB));
+ }
+
+ /**
+ * Updates the displayed view based on the selected filter option
+ */
+ protected void updateCurrentView()
+ {
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ layout_switchableViews.show(pnl_switchableViews,
+ selectedFilterOpt.getView());
+ String filterTitle = mainFrame.getTitle();
+ mainFrame.setTitle(frameTitle);
+ chk_invertFilter.setVisible(false);
+ if (selectedFilterOpt.getView() == VIEWS_FILTER)
+ {
+ mainFrame.setTitle(filterTitle);
+ chk_invertFilter.setVisible(true);
+ filterResultSet(selectedFilterOpt.getValue());
+ }
+ else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
+ || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
+ {
+ mainFrame.setTitle(filterTitle);
+ 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_LOCAL_PDB)
+ {
+ if (tbl_local_pdb.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);
+ lbl_pdbManualFetchStatus.setToolTipText("");
+ if (txt_search.getText().length() > 0)
+ {
+ lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
+ true, "No PDB entry found for \'" + txt_search.getText()
+ + "\'"));
+ }
+
+ if (errorWarning.length() > 0)
+ {
+ lbl_pdbManualFetchStatus.setIcon(warningImage);
+ lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
+ true, errorWarning.toString()));
+ }
+
+ if (selectedSequences.length == 1
+ || !assSeqOpt.getName().equalsIgnoreCase(
+ "-Select Associated Seq-"))
+ {
+ txt_search.setEnabled(true);
+ if (isValidPBDEntry)
+ {
+ btn_view.setEnabled(true);
+ lbl_pdbManualFetchStatus.setToolTipText("");
+ 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);
+ }
+ }