* make things more intuitive by telling the noobs they're doing things wrong, and what to do instead
This commit is contained in:
parent
ee4e373eb1
commit
a6814d6b80
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.ui.rename;
|
package net.sourceforge.filebot.ui.rename;
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
||||||
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
|
@ -28,12 +27,10 @@ import net.sourceforge.tuned.ui.ProgressDialog;
|
||||||
import net.sourceforge.tuned.ui.ProgressDialog.Cancellable;
|
import net.sourceforge.tuned.ui.ProgressDialog.Cancellable;
|
||||||
import net.sourceforge.tuned.ui.SwingWorkerPropertyChangeAdapter;
|
import net.sourceforge.tuned.ui.SwingWorkerPropertyChangeAdapter;
|
||||||
|
|
||||||
|
|
||||||
class MatchAction extends AbstractAction {
|
class MatchAction extends AbstractAction {
|
||||||
|
|
||||||
private final RenameModel model;
|
private final RenameModel model;
|
||||||
|
|
||||||
|
|
||||||
public MatchAction(RenameModel model) {
|
public MatchAction(RenameModel model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
|
||||||
|
@ -42,10 +39,11 @@ class MatchAction extends AbstractAction {
|
||||||
putValue(SHORT_DESCRIPTION, "Match files and names");
|
putValue(SHORT_DESCRIPTION, "Match files and names");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
if (model.names().isEmpty() || model.files().isEmpty())
|
if (model.names().isEmpty() || model.files().isEmpty()) {
|
||||||
|
UILogger.info("Nothing to match. Please add some files and fetch data first.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BackgroundMatcher backgroundMatcher = new BackgroundMatcher(model, EpisodeMetrics.defaultSequence(true));
|
BackgroundMatcher backgroundMatcher = new BackgroundMatcher(model, EpisodeMetrics.defaultSequence(true));
|
||||||
backgroundMatcher.execute();
|
backgroundMatcher.execute();
|
||||||
|
@ -70,7 +68,6 @@ class MatchAction extends AbstractAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ProgressDialog createProgressDialog(Window parent, final BackgroundMatcher worker) {
|
protected ProgressDialog createProgressDialog(Window parent, final BackgroundMatcher worker) {
|
||||||
final ProgressDialog progressDialog = new ProgressDialog(parent, worker);
|
final ProgressDialog progressDialog = new ProgressDialog(parent, worker);
|
||||||
|
|
||||||
|
@ -91,24 +88,20 @@ class MatchAction extends AbstractAction {
|
||||||
return progressDialog;
|
return progressDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected class BackgroundMatcher extends SwingWorker<List<Match<Object, File>>, Void> implements Cancellable {
|
protected class BackgroundMatcher extends SwingWorker<List<Match<Object, File>>, Void> implements Cancellable {
|
||||||
|
|
||||||
private final Matcher<Object, File> matcher;
|
private final Matcher<Object, File> matcher;
|
||||||
|
|
||||||
|
|
||||||
public BackgroundMatcher(MatchModel<Object, File> model, SimilarityMetric[] metrics) {
|
public BackgroundMatcher(MatchModel<Object, File> model, SimilarityMetric[] metrics) {
|
||||||
// match names against files
|
// match names against files
|
||||||
this.matcher = new Matcher<Object, File>(model.values(), model.candidates(), false, metrics);
|
this.matcher = new Matcher<Object, File>(model.values(), model.candidates(), false, metrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Match<Object, File>> doInBackground() throws Exception {
|
protected List<Match<Object, File>> doInBackground() throws Exception {
|
||||||
return matcher.match();
|
return matcher.match();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
if (isCancelled())
|
if (isCancelled())
|
||||||
|
@ -129,7 +122,6 @@ class MatchAction extends AbstractAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cancel() {
|
public boolean cancel() {
|
||||||
return cancel(true);
|
return cancel(true);
|
||||||
|
|
|
@ -71,8 +71,8 @@ class RenameAction extends AbstractAction {
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
Window window = getWindow(evt.getSource());
|
Window window = getWindow(evt.getSource());
|
||||||
try {
|
try {
|
||||||
if (model.getRenameMap().isEmpty()) {
|
if (model.files().isEmpty()) {
|
||||||
UILogger.info("Nothing to rename. Please add some files and create matches first.");
|
UILogger.info("Nothing to rename. Please add some files and fetch data first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
|
@ -53,7 +52,6 @@ import net.sourceforge.filebot.WebServices;
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.ui.Language;
|
||||||
import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture;
|
import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture;
|
||||||
import net.sourceforge.filebot.ui.transfer.LoadAction;
|
|
||||||
import net.sourceforge.filebot.web.AudioTrack;
|
import net.sourceforge.filebot.web.AudioTrack;
|
||||||
import net.sourceforge.filebot.web.AudioTrackFormat;
|
import net.sourceforge.filebot.web.AudioTrackFormat;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
|
@ -131,27 +129,37 @@ public class RenamePanel extends JComponent {
|
||||||
new ScrollPaneSynchronizer(namesList, filesList);
|
new ScrollPaneSynchronizer(namesList, filesList);
|
||||||
|
|
||||||
// delete items from both lists
|
// delete items from both lists
|
||||||
Action removeAction = new AbstractAction("Remove") {
|
Action removeAction = new AbstractAction("Remove", ResourceManager.getIcon("dialog.cancel")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JList list = ((RenameList) e.getSource()).getListComponent();
|
RenameList list = null;
|
||||||
int index = list.getSelectedIndex();
|
boolean deleteCell;
|
||||||
|
|
||||||
|
if (e.getSource() instanceof JButton) {
|
||||||
|
list = filesList;
|
||||||
|
deleteCell = isShiftOrAltDown(e);
|
||||||
|
} else {
|
||||||
|
list = ((RenameList) e.getSource());
|
||||||
|
deleteCell = isShiftOrAltDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = list.getListComponent().getSelectedIndex();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
if (isShiftOrAltDown(e)) {
|
if (deleteCell) {
|
||||||
EventList eventList = ((RenameList) e.getSource()).getModel();
|
EventList eventList = list.getModel();
|
||||||
if (index < eventList.size()) {
|
if (index < eventList.size()) {
|
||||||
((RenameList) e.getSource()).getModel().remove(index);
|
list.getModel().remove(index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
renameModel.matches().remove(index);
|
renameModel.matches().remove(index);
|
||||||
}
|
}
|
||||||
int maxIndex = ((RenameList) e.getSource()).getModel().size() - 1;
|
int maxIndex = list.getModel().size() - 1;
|
||||||
if (index > maxIndex) {
|
if (index > maxIndex) {
|
||||||
index = maxIndex;
|
index = maxIndex;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
list.setSelectedIndex(index);
|
list.getListComponent().setSelectedIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,28 +180,13 @@ public class RenamePanel extends JComponent {
|
||||||
// create fetch popup
|
// create fetch popup
|
||||||
ActionPopup fetchPopup = createFetchPopup();
|
ActionPopup fetchPopup = createFetchPopup();
|
||||||
|
|
||||||
final Action fetchPopupAction = new ShowPopupAction("Fetch", ResourceManager.getIcon("action.fetch"));
|
final Action fetchPopupAction = new ShowPopupAction("Fetch Data", ResourceManager.getIcon("action.fetch"));
|
||||||
JButton fetchButton = new JButton(fetchPopupAction);
|
JButton fetchButton = new JButton(fetchPopupAction);
|
||||||
filesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
filesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
fetchButton.setComponentPopupMenu(fetchPopup);
|
fetchButton.setComponentPopupMenu(fetchPopup);
|
||||||
matchButton.setComponentPopupMenu(fetchPopup);
|
matchButton.setComponentPopupMenu(fetchPopup);
|
||||||
namesList.getButtonPanel().add(fetchButton, "gap 0");
|
namesList.getButtonPanel().add(fetchButton, "gap 0");
|
||||||
matchButton.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// show popup on actionPerformed only when names list is empty
|
|
||||||
if (renameModel.size() == 0) {
|
|
||||||
new LoadAction(filesList.getTransferablePolicy()).actionPerformed(e);
|
|
||||||
if (renameModel.size() > 0) {
|
|
||||||
fetchPopupAction.actionPerformed(e);
|
|
||||||
}
|
|
||||||
} else if (renameModel.size() > 0 && !renameModel.hasComplement(0)) {
|
|
||||||
fetchPopupAction.actionPerformed(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
fetchButton.setComponentPopupMenu(fetchPopup);
|
fetchButton.setComponentPopupMenu(fetchPopup);
|
||||||
|
@ -207,7 +200,8 @@ public class RenamePanel extends JComponent {
|
||||||
namesList.getButtonPanel().add(settingsButton, "gap indent");
|
namesList.getButtonPanel().add(settingsButton, "gap indent");
|
||||||
|
|
||||||
// open rename log button
|
// open rename log button
|
||||||
filesList.getButtonPanel().add(new JButton(clearFilesAction), "gap 0");
|
filesList.getButtonPanel().add(createImageButton(removeAction), "gap 0", 2);
|
||||||
|
filesList.getButtonPanel().add(createImageButton(clearFilesAction), "gap 0");
|
||||||
filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap indent");
|
filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap indent");
|
||||||
|
|
||||||
// reveal file location on double click
|
// reveal file location on double click
|
||||||
|
|
Loading…
Reference in New Issue