return null;
}
+ public String getMessage(long id)
+ {
+ return progressBar.getMessage(id);
+ }
+
+ public void setProgressBarMessage(long id, String message)
+ {
+ progressBar.setProgressBarMessage(id, message);
+ }
+
@Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
return progressBar == null ? false : progressBar.operationInProgress();
}
+
+
/**
* Sets the text of the status bar. Note that setting a null or empty value
* will cause the status bar to be hidden, with possibly undesirable flicker
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
/**
* Progress bars managed by the IProgressIndicator method.
+ * TODO - delegate to jalview.gui.ProgressBar
*/
private Hashtable<Long, JPanel> progressBars;
private Hashtable<Long, IProgressIndicatorHandler> progressBarHandlers;
+
+ private Hashtable<Long, String> progressBarMessages;
/*
* (non-Javadoc)
{
progressBars = new Hashtable<>();
progressBarHandlers = new Hashtable<>();
+ progressBarMessages = new Hashtable<>();
}
if (progressBars.get(Long.valueOf(id)) != null)
else
{
progressBars.put(Long.valueOf(id), addProgressPanel(message));
+ progressBarMessages.put(id, message);
}
}
}
}
+
+ @Override
+ public String getMessage(long id)
+ {
+ return progressBarMessages.get(id);
+ }
+
+ /**
+ * change the text shown alongside a progress bar
+ * @param id
+ * @param message
+ */
+ @Override
+ public void setProgressBarMessage(long id,String message)
+ {
+ Container progBar = progressBars.get(id);
+ if (progBar == null || progBar.getComponentCount() == 0)
+ {
+ return;
+ }
+ for (Component component : progBar.getComponents())
+ {
+ if (component.getClass().equals(JLabel.class))
+ {
+ ((JLabel) component).setText(message);;
+ progBar.revalidate();
+ }
+ }
+ }
+
/**
*
* @return true if any progress bars are still active
*/
public JProgressBar getProgressBar(long id);
+ /**
+ * get the initial message shown when the progress bar was created via setProgressBar
+ * @param id
+ * @return null or the message used
+ */
+ String getMessage(long id);
+
+ /**
+ * change the text shown alongside a progress bar
+ * @param id
+ * @param message
+ */
+ void setProgressBarMessage(long id, String message);
+
}
{
return progressBar.getProgressBar(id);
}
+
+ public String getMessage(long id)
+ {
+ return progressBar.getMessage(id);
+ }
+
+ public void setProgressBarMessage(long id, String message)
+ {
+ progressBar.setProgressBarMessage(id, message);
+ }
}
}
}
- /*
- * (non-Javadoc)
- *
- * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
- */
- @Override
+
public void setProgressBar(String message, long id)
{
progressBar.setProgressBar(message, id);
- // if (progressBars == null)
- // {
- // progressBars = new Hashtable();
- // progressBarHandlers = new Hashtable();
- // }
- //
- // JPanel progressPanel;
- // Long lId = Long.valueOf(id);
- // GridLayout layout = (GridLayout) statusPanel.getLayout();
- // if (progressBars.get(lId) != null)
- // {
- // progressPanel = (JPanel) progressBars.get(Long.valueOf(id));
- // statusPanel.remove(progressPanel);
- // progressBars.remove(lId);
- // progressPanel = null;
- // if (message != null)
- // {
- // statusBar.setText(message);
- // }
- // if (progressBarHandlers.contains(lId))
- // {
- // progressBarHandlers.remove(lId);
- // }
- // layout.setRows(layout.getRows() - 1);
- // }
- // else
- // {
- // progressPanel = new JPanel(new BorderLayout(10, 5));
- //
- // JProgressBar progressBar = new JProgressBar();
- // progressBar.setIndeterminate(true);
- //
- // progressPanel.add(new JLabel(message), BorderLayout.WEST);
- // progressPanel.add(progressBar, BorderLayout.CENTER);
- //
- // layout.setRows(layout.getRows() + 1);
- // statusPanel.add(progressPanel);
- //
- // progressBars.put(lId, progressPanel);
- // }
- // // update GUI
- // // setMenusForViewport();
- // validate();
+ }
+
+ public String getMessage(long id)
+ {
+ return progressBar.getMessage(id);
+ }
+
+ public void setProgressBarMessage(long id, String message)
+ {
+ progressBar.setProgressBarMessage(id, message);
}
/*
* Progress bars in progress, keyed by any arbitrary long value
*/
Map<Long, JPanel> progressBars;
+
+ Map<Long, String> progressBarMessages;
/*
* Optional handlers for the progress bars
this.statusBar = statusBar;
this.progressBars = new Hashtable<>();
this.progressBarHandlers = new Hashtable<>();
+ this.progressBarMessages = new Hashtable<>();
}
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
-
+
progressPanel.add(new JLabel(message), BorderLayout.WEST);
progressPanel.add(progressBar, BorderLayout.CENTER);
addRow(progressPanel);
progressBars.put(id, progressPanel);
+ progressBarMessages.put(id, message);
}
refreshLayout();
/*
*
*/
+ @Override
public JProgressBar getProgressBar(long id)
{
Container progBar = progressBars.get(id);
}
return null;
}
+
+ @Override
+ public String getMessage(long id)
+ {
+ return progressBarMessages.get(id);
+ }
+
+ /**
+ * change the text shown alongside a progress bar
+ * @param id
+ * @param message
+ */
+ @Override
+ public void setProgressBarMessage(long id,String message)
+ {
+ Container progBar = progressBars.get(id);
+ if (progBar == null || progBar.getComponentCount() == 0)
+ {
+ return;
+ }
+ for (Component component : progBar.getComponents())
+ {
+ if (component.getClass().equals(JLabel.class))
+ {
+ ((JLabel) component).setText(message);;
+ refreshLayout();
+ }
+ }
+ }
}
{
return progressBar.getProgressBar(id);
}
+
+ public String getMessage(long id)
+ {
+ return progressIndicator.getMessage(id);
+ }
+
+ public void setProgressBarMessage(long id, String message)
+ {
+ progressIndicator.setProgressBarMessage(id, message);
+ }
}
{
return progressBar.getProgressBar(id);
}
+
+ public String getMessage(long id)
+ {
+ return progressBar.getMessage(id);
+ }
+
+ public void setProgressBarMessage(long id, String message)
+ {
+ progressBar.setProgressBarMessage(id, message);
+ }
}