1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-02 08:25:02 -04:00

* fix JFileChooser default size issues

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=2988
This commit is contained in:
Reinhard Pointner 2015-09-15 07:04:36 +00:00
parent e7f410d895
commit ef215f0d19
3 changed files with 20 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package net.filebot;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static net.filebot.Settings.*;
import static net.filebot.similarity.Normalization.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Desktop;
@ -113,7 +114,7 @@ public class UserFiles {
}
if (filter != null && !filter.acceptAny()) {
chooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter(filter.toString(), filter.extensions()));
chooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter(truncateText(filter.toString(), 80), filter.extensions()));
}
if (chooser.showOpenDialog(getWindow(evt.getSource())) == JFileChooser.APPROVE_OPTION) {

View File

@ -970,24 +970,6 @@ public class MediaBindingBean {
}
}
private String truncateText(String title, int limit) {
if (title.length() < limit) {
return title;
}
String[] words = title.split("\\s+");
StringBuilder s = new StringBuilder();
for (int i = 0; i < words.length && s.length() + words[i].length() < limit; i++) {
if (i > 0) {
s.append(' ');
}
s.append(words[i]);
}
return s.toString().trim();
}
private List<String> getKeywords() {
// collect key information
Set<Object> keys = new HashSet<Object>();

View File

@ -63,4 +63,22 @@ public class Normalization {
return trailingParentheses.matcher(name).replaceAll("").trim();
}
public static String truncateText(String title, int limit) {
if (title.length() < limit) {
return title;
}
String[] words = space.split(title);
StringBuilder s = new StringBuilder();
for (int i = 0; i < words.length && s.length() + words[i].length() < limit; i++) {
if (i > 0) {
s.append(' ');
}
s.append(words[i]);
}
return s.toString().trim();
}
}