* refactoring

This commit is contained in:
Reinhard Pointner 2009-06-30 12:57:09 +00:00
parent 6766e1bb95
commit e8cf2e7029
6 changed files with 44 additions and 13 deletions

View File

@ -164,7 +164,11 @@ public class AssociativeScriptObject implements Scriptable {
public LenientLookup(Map<String, Object> source) {
// populate entry map
for (Entry<String, Object> entry : source.entrySet()) {
this.source.put(definingKey(entry.getKey()), entry);
String key = definingKey(entry.getKey());
if (key.length() > 0) {
this.source.put(key, entry);
}
}
}

View File

@ -72,7 +72,9 @@ public class SubStationAlphaReader extends SubtitleReader {
long start = timeFormat.parse(row[format.get("Start")]).getTime();
long end = timeFormat.parse(row[format.get("End")]).getTime();
String[] lines = row[format.get("Text")].trim().split(Pattern.quote("\\n"));
String text = row[format.get("Text")].trim();
String[] lines = Pattern.compile(Pattern.quote("\\N"), Pattern.CASE_INSENSITIVE).split(text);
return new SubtitleElement(start, end, join(Arrays.asList(lines), "\n"));
}

View File

@ -98,6 +98,16 @@ public class SelectDialog<T> extends JDialog {
}
public Action getSelectAction() {
return selectAction;
}
public Action getCancelAction() {
return cancelAction;
}
private final Action selectAction = new AbstractAction("Select", ResourceManager.getIcon("dialog.continue")) {
public void actionPerformed(ActionEvent e) {

View File

@ -30,6 +30,9 @@ import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import ca.odell.glazedlists.ListSelection;
import ca.odell.glazedlists.swing.EventSelectionModel;
import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.Settings;
@ -53,8 +56,6 @@ import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
import net.sourceforge.tuned.PreferencesMap.SimpleAdapter;
import net.sourceforge.tuned.ui.ActionPopup;
import net.sourceforge.tuned.ui.LoadingOverlayPane;
import ca.odell.glazedlists.ListSelection;
import ca.odell.glazedlists.swing.EventSelectionModel;
public class RenamePanel extends JComponent {
@ -220,6 +221,7 @@ public class RenamePanel extends JComponent {
return actionPopup;
}
protected final Action showPopupAction = new AbstractAction("Show Popup") {
@Override
@ -310,7 +312,7 @@ public class RenamePanel extends JComponent {
// add remaining file entries
renameModel.files().addAll(remainingFiles());
} catch (Exception e) {
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCauseMessage(e));
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
} finally {
// auto-match finished
namesList.firePropertyChange(LOADING_PROPERTY, true, false);
@ -324,7 +326,7 @@ public class RenamePanel extends JComponent {
return searchResults.iterator().next();
}
final List<SearchResult> probableMatches = new LinkedList<SearchResult>();
final LinkedList<SearchResult> probableMatches = new LinkedList<SearchResult>();
// use name similarity metric
SimilarityMetric metric = new NameSimilarityMetric();
@ -337,7 +339,7 @@ public class RenamePanel extends JComponent {
}
if (probableMatches.size() == 1) {
return probableMatches.get(0);
return probableMatches.getFirst();
}
// show selection dialog on EDT
@ -351,8 +353,10 @@ public class RenamePanel extends JComponent {
// multiple results have been found, user must select one
SelectDialog<SearchResult> selectDialog = new SelectDialog<SearchResult>(getWindow(RenamePanel.this), selection);
selectDialog.getHeaderLabel().setText(String.format("Shows matching \"%s\":", query));
selectDialog.getHeaderLabel().setText(String.format("Shows matching '%s':", query));
selectDialog.getCancelAction().putValue(Action.NAME, "Ignore");
// show dialog
selectDialog.setVisible(true);
// selected value or null if the dialog was canceled by the user
@ -372,6 +376,7 @@ public class RenamePanel extends JComponent {
}
}
private final PreferencesEntry<EpisodeExpressionFormatter> persistentExpressionFormatter = Settings.userRoot().entry("rename.format", new AbstractAdapter<EpisodeExpressionFormatter>() {
@Override

View File

@ -285,7 +285,7 @@ public class SubtitleDownloadComponent extends JComponent {
final Object[] selection = list.getSelectedValues();
Action downloadAction = new AbstractAction("Download", ResourceManager.getIcon("action.fetch")) {
Action downloadAction = new AbstractAction("Download", ResourceManager.getIcon("package.fetch")) {
@Override
public void actionPerformed(ActionEvent e) {

View File

@ -168,6 +168,16 @@ public final class FileUtilities {
}
public boolean acceptExtension(String extension) {
for (String other : extensions) {
if (other.equalsIgnoreCase(extension))
return true;
}
return false;
}
public List<String> extensions() {
return Arrays.asList(extensions);
}