package jalview.gui;
+import jalview.bin.Jalview;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
+import jalview.ws.sifts.SiftsSettings;
import jalview.ws.uimodel.PDBRestRequest;
import jalview.ws.uimodel.PDBRestResponse;
import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
*
*/
@SuppressWarnings("serial")
-public class StructureChooser extends GStructureChooser
+public class StructureChooser extends GStructureChooser implements
+ IProgressIndicator
{
private boolean structuresDiscovered = false;
*/
public void init()
{
+ if (!Jalview.isHeadlessMode())
+ {
+ progressBar = new ProgressBar(this.statusPanel, this.statusBar);
+ }
+
Thread discoverPDBStructuresThread = new Thread(new Runnable()
{
@Override
@Override
public void ok_ActionPerformed()
{
+ final long progressSessionId = System.currentTimeMillis();
+ final StructureSelectionManager ssm = ap.getStructureSelectionManager();
+ ssm.setProgressIndicator(this);
+ ssm.setProgressSessionId(progressSessionId);
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
String currentView = selectedFilterOpt.getView();
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- launchStructureViewer(ap.getStructureSelectionManager(),
- pdbEntriesToView, ap, selectedSeqs);
+ launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
}
else if (currentView == VIEWS_LOCAL_PDB)
{
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- launchStructureViewer(ap.getStructureSelectionManager(),
- pdbEntriesToView, ap, selectedSeqs);
+ launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
}
else if (currentView == VIEWS_ENTER_ID)
{
}
PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
- launchStructureViewer(ap.getStructureSelectionManager(),
- pdbEntriesToView, ap, new SequenceI[] { selectedSequence });
+ launchStructureViewer(ssm, pdbEntriesToView, ap,
+ new SequenceI[] { selectedSequence });
}
else if (currentView == VIEWS_FROM_FILE)
{
jalview.io.AppletFormatAdapter.FILE,
selectedSequence, true, Desktop.instance);
- launchStructureViewer(ap.getStructureSelectionManager(),
- new PDBEntry[] { fileEntry }, ap,
- new SequenceI[] { selectedSequence });
+ launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
+ new SequenceI[] { selectedSequence });
}
mainFrame.dispose();
+ }
+ }).start();
}
- private void launchStructureViewer(final StructureSelectionManager ssm,
+ private void launchStructureViewer(StructureSelectionManager ssm,
final PDBEntry[] pdbEntriesToView,
- final AlignmentPanel alignPanel, final SequenceI[] sequences)
+ final AlignmentPanel alignPanel, SequenceI[] sequences)
{
+ ssm.setProgressBar("Launching PDB structure viewer..");
final StructureViewer sViewer = new StructureViewer(ssm);
- new jalview.ws.DBRefFetcher(sequences, null, null, null, false)
- .fetchDBRefs(true);
- new Thread(new Runnable()
+ if (SiftsSettings.isMapWithSifts())
{
- @Override
- public void run()
+ for (SequenceI seq : sequences)
{
+ if (seq.getSourceDBRef() == null)
+ {
+ ssm.setProgressBar(null);
+ ssm.setProgressBar("Fetching Database refs..");
+ new jalview.ws.DBRefFetcher(sequences, null, null, null, false)
+ .fetchDBRefs(true);
+ break;
+ }
+ }
+ }
if (pdbEntriesToView.length > 1)
{
ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
seqsMap.add(new SequenceI[] { seq });
}
SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
+ ssm.setProgressBar(null);
+ ssm.setProgressBar("Fetching PDB Structures for selected entries..");
sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
}
else
{
+ ssm.setProgressBar(null);
+ ssm.setProgressBar("Fetching PDB Structure for "
+ + pdbEntriesToView[0].getId());
sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
}
- }
- }).start();
}
/**
}
}
+
+ private IProgressIndicator progressBar;
+
+ @Override
+ public void setProgressBar(String message, long id)
+ {
+ progressBar.setProgressBar(message, id);
+ }
+
+ @Override
+ public void registerHandler(long id, IProgressIndicatorHandler handler)
+ {
+ progressBar.registerHandler(id, handler);
+ }
+
+ @Override
+ public boolean operationInProgress()
+ {
+ return progressBar.operationInProgress();
+ }
}
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public abstract class GStructureChooser extends JPanel implements
ItemListener
{
+ protected JPanel statusPanel = new JPanel();
+
+ public JLabel statusBar = new JLabel();
+
+ private JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
+
protected String frameTitle = MessageManager
.getString("label.structure_chooser");
protected JTable tbl_summary = new JTable()
{
+ @Override
public String getToolTipText(MouseEvent evt)
{
String toolTipText = null;
tbl_summary.getTableHeader().setReorderingAllowed(false);
tbl_summary.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent e)
{
validateSelections();
}
+ @Override
public void mouseReleased(MouseEvent e)
{
validateSelections();
tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
tbl_local_pdb.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent e)
{
validateSelections();
}
+ @Override
public void mouseReleased(MouseEvent e)
{
validateSelections();
btn_view.setText(MessageManager.getString("action.view"));
btn_view.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_ActionPerformed();
btn_cancel.setText(MessageManager.getString("action.cancel"));
btn_cancel.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
mainFrame.dispose();
btn_pdbFromFile.setText(btn_title + " ");
btn_pdbFromFile.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
pdbFromFile_actionPerformed();
.getString("label.configure_displayed_columns");
ChangeListener changeListener = new ChangeListener()
{
+ @Override
public void stateChanged(ChangeEvent changeEvent)
{
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
this.setLayout(mainLayout);
this.add(pnl_main, java.awt.BorderLayout.NORTH);
this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
- this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
+ // this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
+ statusPanel.setLayout(new GridLayout());
+ pnl_actionsAndStatus.add(pnl_actions, BorderLayout.CENTER);
+ pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH);
+ statusPanel.add(statusBar, null);
+ this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH);
mainFrame.setVisible(true);
mainFrame.setContentPane(this);
this.view = view;
}
+ @Override
public String toString()
{
return this.name;
this.sequence = seq;
}
+ @Override
public String toString()
{
return name;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SequenceI;
+import jalview.gui.IProgressIndicator;
import jalview.io.AppletFormatAdapter;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
private boolean addTempFacAnnot = false;
+ private IProgressIndicator progressIndicator;
+
+ private long progressSessionId;
+
/*
* Set of any registered mappings between (dataset) sequences.
*/
ArrayList<StructureMapping> seqToStrucMapping = null;
if (isMapUsingSIFTs)
{
+ setProgressBar(null);
+ setProgressBar("Obtaining mapping with SIFTS");
try
{
jalview.datamodel.Mapping sqmpping = maxAlignseq
e.printStackTrace();
System.err
.println(">>>>>>> SIFTs mapping could not be obtained... Now mapping with NW alignment");
+ setProgressBar(null);
+ setProgressBar("SIFTs mapping could not be obtained... Now mapping with NW alignment");
seqToStrucMapping = getNWMappings(seq, pdbFile, maxChainId,
maxChain, pdb, maxAlignseq);
}
}
else
{
+ setProgressBar(null);
+ setProgressBar("Obtaining mapping with NW alignment");
seqToStrucMapping = getNWMappings(seq, pdbFile,
maxChainId, maxChain, pdb,
maxAlignseq);
}
return null;
}
+
+ public IProgressIndicator getProgressIndicator()
+ {
+ return progressIndicator;
+ }
+
+ public void setProgressIndicator(IProgressIndicator progressIndicator)
+ {
+ this.progressIndicator = progressIndicator;
+ }
+
+ public long getProgressSessionId()
+ {
+ return progressSessionId;
+ }
+
+ public void setProgressSessionId(long progressSessionId)
+ {
+ this.progressSessionId = progressSessionId;
+ }
+
+ public void setProgressBar(String message)
+ {
+ progressIndicator.setProgressBar(message, progressSessionId);
+ }
+
}