X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fload%2FMediaLoadProgressDialog.java;h=9372704ade85ae469ee367695464f6c611cafe7c;hp=a052b55d14fca6dabc18497775575005945410bd;hb=326f489e36aa7f235bc19409a57bf4955cd50f24;hpb=8c8868ae29b3252f02e094c02307384cf61ba667 diff --git a/tim/prune/load/MediaLoadProgressDialog.java b/tim/prune/load/MediaLoadProgressDialog.java index a052b55..9372704 100644 --- a/tim/prune/load/MediaLoadProgressDialog.java +++ b/tim/prune/load/MediaLoadProgressDialog.java @@ -1,32 +1,17 @@ package tim.prune.load; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JDialog; import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import tim.prune.I18nManager; import tim.prune.function.Cancellable; +import tim.prune.gui.GenericProgressDialog; /** * Class to show a progress dialog for loading media. - * Used for regular photo / audio loads plus the async - * loading function. + * Used for regular photo / audio loads plus the async loading function. + * Maybe this class isn't really needed... */ -public class MediaLoadProgressDialog +public class MediaLoadProgressDialog extends GenericProgressDialog { - private JDialog _progressDialog = null; - private JProgressBar _progressBar = null; - private JFrame _parentFrame = null; - private Cancellable _function = null; - /** * Constructor * @param inParentFrame parent frame for creating dialog @@ -34,74 +19,6 @@ public class MediaLoadProgressDialog */ public MediaLoadProgressDialog(JFrame inParentFrame, Cancellable inFunction) { - _parentFrame = inParentFrame; - _function = inFunction; - } - - /** - * Create the dialog to show the progress - */ - private void createProgressDialog() - { - _progressDialog = new JDialog(_parentFrame, I18nManager.getText("dialog.jpegload.progress.title")); - _progressDialog.setLocationRelativeTo(_parentFrame); - _progressBar = new JProgressBar(0, 100); - _progressBar.setValue(0); - _progressBar.setStringPainted(true); - _progressBar.setString(""); - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - panel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - panel.add(new JLabel(I18nManager.getText("dialog.jpegload.progress"))); - panel.add(_progressBar); - JButton cancelButton = new JButton(I18nManager.getText("button.cancel")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - _function.cancel(); - } - }); - panel.add(cancelButton); - _progressDialog.getContentPane().add(panel); - _progressDialog.pack(); - _progressDialog.setVisible(true); - } - - /** - * Show the dialog in indeterminate mode, before limits are calculated - */ - public void show() - { - if (_progressDialog == null) - { - createProgressDialog(); - _progressBar.setIndeterminate(true); - } - } - - /** - * Update the progress bar - * @param inCurrent current value - * @param inMax maximum value - */ - public void showProgress(int inCurrent, int inMax) - { - if (_progressDialog == null) - createProgressDialog(); - if (_progressBar.isIndeterminate()) - _progressBar.setIndeterminate(false); - if (inMax > 0) - _progressBar.setMaximum(inMax); - _progressBar.setValue(inCurrent); - _progressBar.setString("" + inCurrent + " / " + _progressBar.getMaximum()); - } - - /** - * Close the dialog - */ - public void close() - { - if (_progressDialog != null) - _progressDialog.dispose(); + super("dialog.jpegload.progress.title", "dialog.jpegload.progress", inParentFrame, inFunction); } }