import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
+import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
public class StructureChooser extends GStructureChooser
implements IProgressIndicator
{
- private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
+ protected static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
/**
* warn user if need to fetch more than this many uniprot records at once
*/
private static final int THRESHOLD_WARN_UNIPROT_FETCH_NEEDED = 20;
-
private SequenceI selectedSequence;
private SequenceI[] selectedSequences;
List<SequenceI> seqsWithoutSourceDBRef = null;
- private static StructureViewer lastTargetedView = null;
+ protected static StructureViewer lastTargetedView = null;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
previousWantedFields = null;
lastSelected = (FilterOption) cmb_filterOption.getSelectedItem();
cmb_filterOption.setSelectedItem(null);
- cachedPDBExists = false; // reset to initial
+ cachedPDBExists=false; // reset to initial
initialStructureDiscovery();
if (!isStructuresDiscovered())
{
final FetchFinishedListenerI afterDbRefFetch = new FetchFinishedListenerI()
{
-
+
@Override
public void finished()
{
notQueriedTDBYet = false;
// new thread to discover structures - via 3d beacons
Executors.defaultThreadFactory().newThread(strucDiscovery).start();
-
+
}
};
-
+
// fetch db refs if OK pressed
- final Runnable discoverCanonicalDBrefs = new Runnable()
+ final Runnable discoverCanonicalDBrefs = new Runnable()
{
@Override
public void run()
{ new jalview.ws.dbsources.Uniprot() }, null, false);
dbRefFetcher.addListener(afterDbRefFetch);
// ideally this would also gracefully run with callbacks
-
dbRefFetcher.fetchDBRefs(true);
}
else
Console.debug("Using Uniprot fetch threshold of " + threshold);
if (ignoreGui || seqsWithoutSourceDBRef.size() < threshold)
{
- Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs)
- .start();
+ Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs).start();
return;
}
// need cancel and no to result in the discoverPDB action - mocked is
// 'cancel' TODO: mock should be OK
-
StructureChooser thisSC = this;
JvOptionPane.newOptionDialog(thisSC.getFrame())
.setResponseHandler(JvOptionPane.OK_OPTION,
MessageManager.formatMessage(
"label.fetch_references_for_3dbeacons",
seqsWithoutSourceDBRef.size()),
- MessageManager.getString("label.3dbeacons"),
+ MessageManager
+ .getString("label.3dbeacons"),
JvOptionPane.YES_NO_OPTION, JvOptionPane.PLAIN_MESSAGE,
null, new Object[]
{ MessageManager.getString("action.ok"),
*/
private void discoverStructureViews()
{
- if (Desktop.instance != null)
+ if (Desktop.getInstance() != null)
{
targetView.removeAllItems();
if (lastTargetedView != null && !lastTargetedView.isVisible())
lastTargetedView = null;
}
int linkedViewsAt = 0;
- for (StructureViewerBase view : Desktop.instance
+ for (StructureViewerBase view : Desktop.getInstance()
.getStructureViewers(null, null))
{
StructureViewer viewHandler = (lastTargetedView != null
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
-
+
if (lastSelected == selectedFilterOpt)
{
// don't need to do anything, probably
String filterTitle = mainFrame.getTitle();
mainFrame.setTitle(frameTitle);
chk_invertFilter.setVisible(false);
-
+
if (selectedFilterOpt.getView() == VIEWS_FILTER)
{
mainFrame.setTitle(filterTitle);
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
String currentView = selectedFilterOpt.getView();
-
if (currentView == VIEWS_FILTER
&& data instanceof ThreeDBStructureChooserQuerySource)
{
-
TDB_FTSData row = ((ThreeDBStructureChooserQuerySource) data)
.getFTSDataFor(getResultTable(), selectedRow,
discoveredStructuresSet);
// event not handled by us
return false;
}
-
/**
* Validates inputs from the Manual PDB entry panel
*/
{
validateSelections();
}
-
- private FilterOption lastSelected = null;
-
+ private FilterOption lastSelected=null;
/**
* Handles the state change event for the 'filter' combo-box and 'invert'
* check-box
{
final StructureSelectionManager ssm = ap.getStructureSelectionManager();
-
+ final StructureViewer theViewer = getTargetedStructureViewer(ssm);
+ boolean superimpose = chk_superpose.isSelected();
final int preferredHeight = pnl_filter.getHeight();
Runnable viewStruc = new Runnable()
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap,
- selectedSeqs);
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
+ selectedSeqs, superimpose, theViewer, progressBar);
}
else if (currentView == VIEWS_LOCAL_PDB)
{
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap,
- selectedSeqs);
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
+ selectedSeqs, superimpose, theViewer, progressBar);
}
else if (currentView == VIEWS_ENTER_ID)
{
if (pdbIdStr.split(":").length > 1)
{
pdbEntry.setId(pdbIdStr.split(":")[0]);
- pdbEntry.setChainCode(
- pdbIdStr.split(":")[1].toUpperCase(Locale.ROOT));
+ pdbEntry.setChainCode(pdbIdStr.split(":")[1].toUpperCase(Locale.ROOT));
}
else
{
}
PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
- sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap,
- new SequenceI[]
- { selectedSequence });
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
+ new SequenceI[]
+ { selectedSequence }, superimpose, theViewer,
+ progressBar);
}
else if (currentView == VIEWS_FROM_FILE)
{
{
selectedSequence = userSelectedSeq;
}
- PDBEntry fileEntry = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq(selectedPdbFileName,
- DataSourceType.FILE, selectedSequence, true,
- Desktop.instance);
-
- sViewer = launchStructureViewer(ssm, new PDBEntry[] { fileEntry },
- ap, new SequenceI[]
- { selectedSequence });
+ PDBEntry fileEntry = AssociatePdbFileWithSeq.associatePdbWithSeq(selectedPdbFileName,
+ DataSourceType.FILE, selectedSequence, true);
+
+ sViewer = StructureViewer.launchStructureViewer(ap, new PDBEntry[] { fileEntry },
+ new SequenceI[] { selectedSequence }, superimpose, theViewer,
+ progressBar);
}
SwingUtilities.invokeLater(new Runnable()
{
}
/**
- * Adds PDB structures to a new or existing structure viewer
- *
- * @param ssm
- * @param pdbEntriesToView
- * @param alignPanel
- * @param sequences
- * @return
- */
- private StructureViewer launchStructureViewer(
- StructureSelectionManager ssm, final PDBEntry[] pdbEntriesToView,
- final AlignmentPanel alignPanel, SequenceI[] sequences)
- {
- long progressId = sequences.hashCode();
- setProgressBar(MessageManager
- .getString("status.launching_3d_structure_viewer"), progressId);
- final StructureViewer theViewer = getTargetedStructureViewer(ssm);
- boolean superimpose = chk_superpose.isSelected();
- theViewer.setSuperpose(superimpose);
-
- /*
- * remember user's choice of superimpose or not
- */
- Cache.setProperty(AUTOSUPERIMPOSE,
- Boolean.valueOf(superimpose).toString());
-
- setProgressBar(null, progressId);
- if (SiftsSettings.isMapWithSifts())
- {
- List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<>();
- int p = 0;
- // TODO: skip PDBEntry:Sequence pairs where PDBEntry doesn't look like a
- // real PDB ID. For moment, we can also safely do this if there is already
- // a known mapping between the PDBEntry and the sequence.
- for (SequenceI seq : sequences)
- {
- PDBEntry pdbe = pdbEntriesToView[p++];
- if (pdbe != null && pdbe.getFile() != null)
- {
- StructureMapping[] smm = ssm.getMapping(pdbe.getFile());
- if (smm != null && smm.length > 0)
- {
- for (StructureMapping sm : smm)
- {
- if (sm.getSequence() == seq)
- {
- continue;
- }
- }
- }
- }
- if (seq.getPrimaryDBRefs().isEmpty())
- {
- seqsWithoutSourceDBRef.add(seq);
- continue;
- }
- }
- if (!seqsWithoutSourceDBRef.isEmpty())
- {
- int y = seqsWithoutSourceDBRef.size();
- setProgressBar(MessageManager.formatMessage(
- "status.fetching_dbrefs_for_sequences_without_valid_refs",
- y), progressId);
- SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef
- .toArray(new SequenceI[y]);
- DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef);
- dbRefFetcher.fetchDBRefs(true);
-
- setProgressBar("Fetch complete.", progressId); // todo i18n
- }
- }
- if (pdbEntriesToView.length > 1)
- {
- setProgressBar(
- MessageManager.getString(
- "status.fetching_3d_structures_for_selected_entries"),
- progressId);
- theViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
- }
- else
- {
- setProgressBar(MessageManager.formatMessage(
- "status.fetching_3d_structures_for",
- pdbEntriesToView[0].getId()), progressId);
- theViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
- }
- setProgressBar(null, progressId);
- // remember the last viewer we used...
- lastTargetedView = theViewer;
- return theViewer;
- }
-
- /**
* Populates the combo-box used in associating manually fetched structures to
* a unique sequence when more than one sequence selection is made.
*/
{
progressBar.setProgressBar(message, id);
}
+
+ @Override
+ public void removeProgressBar(long id)
+ {
+ progressBar.removeProgressBar(id);
+ }
@Override
public void registerHandler(long id, IProgressIndicatorHandler handler)
&& mainFrame.isVisible()
&& cmb_filterOption.getSelectedItem() != null;
}
-
/**
*
* @return true if the 3D-Beacons query button will/has been displayed