1 | |
package org.jtheque.films.view.impl.actions.auto.imports; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.beans.IBeansManager; |
21 | |
import org.jtheque.core.managers.view.able.IViewManager; |
22 | |
import org.jtheque.core.managers.view.edt.SimpleTask; |
23 | |
import org.jtheque.core.managers.view.impl.actions.JThequeAction; |
24 | |
import org.jtheque.films.persistence.od.able.Film; |
25 | |
import org.jtheque.films.services.able.IAutoImportService; |
26 | |
import org.jtheque.films.services.able.IFilmsService; |
27 | |
import org.jtheque.films.view.able.IAutoImportView; |
28 | |
|
29 | |
import javax.annotation.Resource; |
30 | |
import java.awt.event.ActionEvent; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public final class AcValidateAutoImportView extends JThequeAction { |
39 | |
@Resource |
40 | |
private IAutoImportService service; |
41 | |
|
42 | |
@Resource |
43 | |
private IFilmsService filmsService; |
44 | |
|
45 | |
@Resource |
46 | |
private IAutoImportView autoImportView; |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
public AcValidateAutoImportView() { |
52 | 0 | super("auto.import.view.actions.import"); |
53 | |
|
54 | 0 | Managers.getManager(IBeansManager.class).inject(this); |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
public void actionPerformed(ActionEvent arg0) { |
59 | 0 | if (autoImportView.validateContent(IAutoImportView.PHASE_2)) { |
60 | 0 | Managers.getManager(IViewManager.class).execute(new SimpleTask() { |
61 | |
@Override |
62 | |
public void run() { |
63 | 0 | autoImportView.startWait(); |
64 | |
|
65 | 0 | new Thread(new ImportFilmsRunnable()).start(); |
66 | 0 | } |
67 | |
}); |
68 | |
} |
69 | 0 | } |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | 0 | private final class ImportFilmsRunnable implements Runnable { |
77 | |
@Override |
78 | |
public void run() { |
79 | 0 | Collection<Film> films = service.importFilms(autoImportView.getModel().getTitles(), autoImportView.isWebMode(), autoImportView.getSelectedSite()); |
80 | |
|
81 | 0 | filmsService.createAll(films); |
82 | |
|
83 | 0 | autoImportView.stopWait(); |
84 | 0 | } |
85 | |
} |
86 | |
} |