Object url = fc.getSelectedFile().getAbsolutePath();
if (url != null && !url.toString().isEmpty()) {
Progress pg = new Progress();
- add(pg, "File");
+ add(pg, "File", fc.getSelectedFile().getName());
Actions.imprt(parent, url.toString(), pg, new Runnable() {
@Override
}
if (url != null && !url.isEmpty()) {
- add(pg, basename);
+ add(pg, basename, null);
Actions.imprt(parent, url, pg, new Runnable() {
@Override
}
}
- private void add(Progress pg, final String basename) {
- final ImporterItem item = new ImporterItem(pg, basename);
+ private void add(Progress pg, final String basename, String storyName) {
+ final ImporterItem item = new ImporterItem(pg, basename, storyName);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
data.filter(new Predicate<ImporterItem>() {
@Override
public boolean test(ImporterItem item) {
- String text = item.getStoryName() + " " + item.getAction();
- return filter.isEmpty() || text.isEmpty()
- || text.toLowerCase().contains(filter.toLowerCase());
+ if (filter.isEmpty())
+ return true;
+
+ if (item.getStoryName().isEmpty() && item.getAction().isEmpty())
+ return true;
+
+ if (item.getStoryName().toLowerCase()
+ .contains(filter.toLowerCase()))
+ return true;
+
+ if (item.getAction().toLowerCase()
+ .contains(filter.toLowerCase()))
+ return true;
+
+ return false;
}
});
}
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
+import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix_swing.gui.utils.CoverImager;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.Progress.ProgressListener;
private JLabel labelName;
private JLabel labelAction;
- public ImporterItem(Progress pg, String basename) {
+ public ImporterItem(Progress pg, String basename, String storyName) {
this.basename = basename == null ? "" : basename;
+ this.storyName = storyName == null ? "" : storyName;
labelName = new JLabel(getStoryName());
labelAction = new JLabel(getAction());
pg.addProgressListener(new ProgressListener() {
@Override
public void progress(Progress notUsed, String currentAction) {
- // TODO: get/setSubject on Progress?
currentAction = currentAction == null ? "" : currentAction;
-
- if (storyName.isEmpty()
- && !currentAction.equals("Initialising")) {
- storyName = currentAction;
- }
-
- if (storyName.equals(currentAction)) {
- currentAction = "";
+ String currentStoryName = null;
+
+ MetaData meta = (MetaData)pg.get("meta");
+ if (meta != null) {
+ currentStoryName = meta.getTitle();
}
-
+
if (pg.getRelativeProgress() != progress
- || !action.equals(currentAction)) {
+ || !action.equals(currentAction)
+ || !storyName.equals(currentStoryName)) {
progress = pg.getRelativeProgress();
action = currentAction;
+ storyName = currentStoryName == null ? ""
+ : currentStoryName;
// The rest must be done in the UI thread
SwingUtilities.invokeLater(new Runnable() {