* refactoring
This commit is contained in:
parent
6766e1bb95
commit
e8cf2e7029
|
@ -164,7 +164,11 @@ public class AssociativeScriptObject implements Scriptable {
|
||||||
public LenientLookup(Map<String, Object> source) {
|
public LenientLookup(Map<String, Object> source) {
|
||||||
// populate entry map
|
// populate entry map
|
||||||
for (Entry<String, Object> entry : source.entrySet()) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,9 @@ public class SubStationAlphaReader extends SubtitleReader {
|
||||||
|
|
||||||
long start = timeFormat.parse(row[format.get("Start")]).getTime();
|
long start = timeFormat.parse(row[format.get("Start")]).getTime();
|
||||||
long end = timeFormat.parse(row[format.get("End")]).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"));
|
return new SubtitleElement(start, end, join(Arrays.asList(lines), "\n"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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")) {
|
private final Action selectAction = new AbstractAction("Select", ResourceManager.getIcon("dialog.continue")) {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
|
@ -30,6 +30,9 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import ca.odell.glazedlists.ListSelection;
|
||||||
|
import ca.odell.glazedlists.swing.EventSelectionModel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.Settings;
|
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.PreferencesMap.SimpleAdapter;
|
||||||
import net.sourceforge.tuned.ui.ActionPopup;
|
import net.sourceforge.tuned.ui.ActionPopup;
|
||||||
import net.sourceforge.tuned.ui.LoadingOverlayPane;
|
import net.sourceforge.tuned.ui.LoadingOverlayPane;
|
||||||
import ca.odell.glazedlists.ListSelection;
|
|
||||||
import ca.odell.glazedlists.swing.EventSelectionModel;
|
|
||||||
|
|
||||||
|
|
||||||
public class RenamePanel extends JComponent {
|
public class RenamePanel extends JComponent {
|
||||||
|
@ -71,7 +72,7 @@ public class RenamePanel extends JComponent {
|
||||||
|
|
||||||
private final PreferencesEntry<Boolean> persistentPreserveExtension = Settings.userRoot().entry("rename.extension.preserve", SimpleAdapter.forClass(Boolean.class));
|
private final PreferencesEntry<Boolean> persistentPreserveExtension = Settings.userRoot().entry("rename.extension.preserve", SimpleAdapter.forClass(Boolean.class));
|
||||||
|
|
||||||
|
|
||||||
public RenamePanel() {
|
public RenamePanel() {
|
||||||
namesList.setTitle("New Names");
|
namesList.setTitle("New Names");
|
||||||
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
||||||
|
@ -220,6 +221,7 @@ public class RenamePanel extends JComponent {
|
||||||
return actionPopup;
|
return actionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected final Action showPopupAction = new AbstractAction("Show Popup") {
|
protected final Action showPopupAction = new AbstractAction("Show Popup") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -234,12 +236,12 @@ public class RenamePanel extends JComponent {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected class PreserveExtensionAction extends AbstractAction {
|
protected class PreserveExtensionAction extends AbstractAction {
|
||||||
|
|
||||||
private final boolean activate;
|
private final boolean activate;
|
||||||
|
|
||||||
|
|
||||||
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
|
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
this.activate = activate;
|
this.activate = activate;
|
||||||
|
@ -266,7 +268,7 @@ public class RenamePanel extends JComponent {
|
||||||
|
|
||||||
private final EpisodeListProvider provider;
|
private final EpisodeListProvider provider;
|
||||||
|
|
||||||
|
|
||||||
public AutoFetchEpisodeListAction(EpisodeListProvider provider) {
|
public AutoFetchEpisodeListAction(EpisodeListProvider provider) {
|
||||||
super(provider.getName(), provider.getIcon());
|
super(provider.getName(), provider.getIcon());
|
||||||
|
|
||||||
|
@ -310,7 +312,7 @@ public class RenamePanel extends JComponent {
|
||||||
// add remaining file entries
|
// add remaining file entries
|
||||||
renameModel.files().addAll(remainingFiles());
|
renameModel.files().addAll(remainingFiles());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCauseMessage(e));
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
} finally {
|
} finally {
|
||||||
// auto-match finished
|
// auto-match finished
|
||||||
namesList.firePropertyChange(LOADING_PROPERTY, true, false);
|
namesList.firePropertyChange(LOADING_PROPERTY, true, false);
|
||||||
|
@ -324,7 +326,7 @@ public class RenamePanel extends JComponent {
|
||||||
return searchResults.iterator().next();
|
return searchResults.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SearchResult> probableMatches = new LinkedList<SearchResult>();
|
final LinkedList<SearchResult> probableMatches = new LinkedList<SearchResult>();
|
||||||
|
|
||||||
// use name similarity metric
|
// use name similarity metric
|
||||||
SimilarityMetric metric = new NameSimilarityMetric();
|
SimilarityMetric metric = new NameSimilarityMetric();
|
||||||
|
@ -337,7 +339,7 @@ public class RenamePanel extends JComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probableMatches.size() == 1) {
|
if (probableMatches.size() == 1) {
|
||||||
return probableMatches.get(0);
|
return probableMatches.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
// show selection dialog on EDT
|
// show selection dialog on EDT
|
||||||
|
@ -351,8 +353,10 @@ public class RenamePanel extends JComponent {
|
||||||
// multiple results have been found, user must select one
|
// multiple results have been found, user must select one
|
||||||
SelectDialog<SearchResult> selectDialog = new SelectDialog<SearchResult>(getWindow(RenamePanel.this), selection);
|
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);
|
selectDialog.setVisible(true);
|
||||||
|
|
||||||
// selected value or null if the dialog was canceled by the user
|
// 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>() {
|
private final PreferencesEntry<EpisodeExpressionFormatter> persistentExpressionFormatter = Settings.userRoot().entry("rename.format", new AbstractAdapter<EpisodeExpressionFormatter>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -285,7 +285,7 @@ public class SubtitleDownloadComponent extends JComponent {
|
||||||
|
|
||||||
final Object[] selection = list.getSelectedValues();
|
final Object[] selection = list.getSelectedValues();
|
||||||
|
|
||||||
Action downloadAction = new AbstractAction("Download", ResourceManager.getIcon("action.fetch")) {
|
Action downloadAction = new AbstractAction("Download", ResourceManager.getIcon("package.fetch")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
|
@ -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() {
|
public List<String> extensions() {
|
||||||
return Arrays.asList(extensions);
|
return Arrays.asList(extensions);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue