* small fixes for our hack of an UI Move/Copy Dialog

This commit is contained in:
Reinhard Pointner 2014-09-21 16:51:20 +00:00
parent c509cb5f46
commit 327ea294c1
2 changed files with 33 additions and 39 deletions

View File

@ -259,7 +259,7 @@ class RenameAction extends AbstractAction {
final ProgressDialog dialog = new ProgressDialog(parent, job); final ProgressDialog dialog = new ProgressDialog(parent, job);
// configure dialog // configure dialog
dialog.setTitle("Moving files..."); dialog.setTitle("Processing files...");
dialog.setIcon((Icon) getValue(SMALL_ICON)); dialog.setIcon((Icon) getValue(SMALL_ICON));
// close progress dialog when worker is finished // close progress dialog when worker is finished
@ -271,8 +271,14 @@ class RenameAction extends AbstractAction {
int i = job.renameLog.size(); int i = job.renameLog.size();
int n = job.renameMap.size(); int n = job.renameMap.size();
dialog.setNote(String.format("%d of %d", i + 1, n)); dialog.setNote(String.format("%d of %d", i + 1, n));
// OSX LaF progress bar may not display progress bar text in indeterminate mode
if (isMacApp()) {
dialog.setTitle("Processing files... " + String.format("%d of %d", i + 1, n));
}
if (newValue instanceof File) { if (newValue instanceof File) {
dialog.setWindowTitle("Moving " + ((File) oldValue).getName()); dialog.setWindowTitle("Processing " + ((File) oldValue).getName());
} }
} }
} }

View File

@ -1,7 +1,6 @@
package net.filebot.util.ui; package net.filebot.util.ui;
import java.awt.Cursor;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -16,97 +15,86 @@ import javax.swing.JProgressBar;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
public class ProgressDialog extends JDialog { public class ProgressDialog extends JDialog {
private final JProgressBar progressBar = new JProgressBar(0, 100); private final JProgressBar progressBar = new JProgressBar(0, 100);
private final JLabel iconLabel = new JLabel(); private final JLabel iconLabel = new JLabel();
private final JLabel headerLabel = new JLabel(); private final JLabel headerLabel = new JLabel();
private final Cancellable cancellable; private final Cancellable cancellable;
public ProgressDialog(Window owner, Cancellable cancellable) { public ProgressDialog(Window owner, Cancellable cancellable) {
super(owner, ModalityType.DOCUMENT_MODAL); super(owner, ModalityType.DOCUMENT_MODAL);
this.cancellable = cancellable; this.cancellable = cancellable;
// disable window close button // disable window close button
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
headerLabel.setFont(headerLabel.getFont().deriveFont(18f)); headerLabel.setFont(headerLabel.getFont().deriveFont(18f));
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);
progressBar.setStringPainted(true); progressBar.setStringPainted(true);
JPanel c = (JPanel) getContentPane(); JPanel c = (JPanel) getContentPane();
c.setLayout(new MigLayout("insets dialog, nogrid, fill")); c.setLayout(new MigLayout("insets dialog, nogrid, fill"));
c.add(iconLabel, "h pref!, w pref!"); c.add(iconLabel, "h pref!, w pref!");
c.add(headerLabel, "gap 3mm, wrap paragraph"); c.add(headerLabel, "gap 3mm, wrap paragraph");
c.add(progressBar, "hmin 25px, grow, wrap paragraph"); c.add(progressBar, "hmin 25px, grow, wrap paragraph");
c.add(new JButton(cancelAction), "align center"); c.add(new JButton(cancelAction), "align center");
setSize(240, 155); setSize(350, 155);
} }
public void setIcon(Icon icon) { public void setIcon(Icon icon) {
iconLabel.setIcon(icon); iconLabel.setIcon(icon);
} }
public void setIndeterminate(boolean b) { public void setIndeterminate(boolean b) {
progressBar.setIndeterminate(b); progressBar.setIndeterminate(b);
} }
public void setProgress(int value, int max) { public void setProgress(int value, int max) {
progressBar.setIndeterminate(false); progressBar.setIndeterminate(false);
progressBar.setMinimum(0); progressBar.setMinimum(0);
progressBar.setValue(value); progressBar.setValue(value);
progressBar.setMaximum(max); progressBar.setMaximum(max);
} }
public void setNote(String text) { public void setNote(String text) {
progressBar.setString(text); progressBar.setString(text);
} }
@Override @Override
public void setTitle(String text) { public void setTitle(String text) {
super.setTitle(text); super.setTitle(text);
headerLabel.setText(text); headerLabel.setText(text);
} }
public void setWindowTitle(String text) { public void setWindowTitle(String text) {
super.setTitle(text); super.setTitle(text);
} }
public void close() { public void close() {
setVisible(false); setVisible(false);
dispose(); dispose();
} }
protected final Action cancelAction = new AbstractAction("Cancel") { protected final Action cancelAction = new AbstractAction("Cancel") {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
cancelAction.setEnabled(false); cancelAction.setEnabled(false);
cancellable.cancel(); cancellable.cancel();
} }
}; };
public static interface Cancellable { public static interface Cancellable {
boolean isCancelled(); boolean isCancelled();
boolean cancel(); boolean cancel();
} }
} }