status.fetching_db_refs = Fetching db refs
status.loading_cached_pdb_entries = Loading Cached PDB Entries
status.searching_for_pdb_structures = Searching for PDB Structures
+status.opening_file = opening file
+status.colouring_chimera = Colouring Chimera
label.font_doesnt_have_letters_defined = Font doesn't have letters defined\nso cannot be used\nwith alignment data
label.font_too_small = Font size is too small
label.error_loading_file_params = Error loading file {0}
info.enter_search_text_to_enable = Enter Search Text to Enable
info.search_in_annotation_label = Search in {0} Label
info.search_in_annotation_description = Search in {0} Description
-info.change_threshold_mode_to_enable = Change Threshold Mode to Enable
\ No newline at end of file
+info.change_threshold_mode_to_enable = Change Threshold Mode to Enable
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Random;
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
*/
private String chimeraSessionFile = null;
+ private Random random = new Random();
+
/**
* Initialise menu options.
*/
{ seq });
}
+ /**
+ * Create a helper to manage progress bar display
+ */
+ protected void createProgressBar()
+ {
+ if (progressBar == null)
+ {
+ progressBar = new ProgressBar(statusPanel, statusBar);
+ }
+ }
+
protected boolean hasPdbId(String pdbId)
{
return jmb.hasPdbId(pdbId);
private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
- progressBar = ap.alignFrame;
+ createProgressBar();
+
jmb = new JalviewChimeraBindingModel(this,
ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
addAlignmentPanel(ap);
try
{
int pos = filePDBpos.get(num).intValue();
+ long startTime = startProgressBar("Chimera "
+ + MessageManager.getString("status.opening_file"));
jmb.openFile(pe);
jmb.addSequence(pos, jmb.getSequence()[pos]);
File fl = new File(pe.getFile());
}
} catch (Throwable e)
{
+ } finally
+ {
+ stopProgressBar("", startTime);
}
// Explicitly map to the filename used by Chimera ;
// TODO: use pe.getId() instead of pe.getFile() ?
Pdb pdbclient = new Pdb();
AlignmentI pdbseq = null;
String pdbid = processingEntry.getId();
- long hdl = pdbid.hashCode() - System.currentTimeMillis();
- if (progressBar != null)
- {
- progressBar.setProgressBar(MessageManager.formatMessage(
- "status.fetching_pdb", new Object[]
- { pdbid }), hdl);
- }
+ long hdl = startProgressBar(MessageManager.formatMessage(
+ "status.fetching_pdb", new Object[]
+ { pdbid }));
try
{
pdbseq = pdbclient.getSequenceRecords(pdbid);
new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
} finally
{
- if (progressBar != null)
- {
- progressBar
- .setProgressBar(
- pdbid
- + " "
- + MessageManager
- .getString("label.state_completed"),
- hdl);
- }
+ String msg = pdbid + " "
+ + MessageManager.getString("label.state_completed");
+ stopProgressBar(msg, hdl);
}
/*
* If PDB data were saved and are not invalid (empty alignment), return the
return filePath;
}
+ /**
+ * Convenience method to update the progress bar if there is one. Be sure to
+ * call stopProgressBar with the returned handle to remove the message.
+ *
+ * @param msg
+ * @param handle
+ */
+ public long startProgressBar(String msg)
+ {
+ // TODO would rather have startProgress/stopProgress as the
+ // IProgressIndicator interface
+ long tm = random.nextLong();
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(msg, tm);
+ }
+ return tm;
+ }
+
+ public void stopProgressBar(String msg, long handle)
+ {
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(msg, handle);
+ }
+ }
+
@Override
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{