| 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.services.able.IAutoImportService; |
| 25 | |
import org.jtheque.films.view.able.IAutoImportView; |
| 26 | |
|
| 27 | |
import javax.annotation.Resource; |
| 28 | |
import java.awt.event.ActionEvent; |
| 29 | |
import java.io.File; |
| 30 | |
import java.util.Collection; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public final class AcSearchTitles extends JThequeAction { |
| 38 | |
@Resource |
| 39 | |
private IAutoImportService service; |
| 40 | |
|
| 41 | |
@Resource |
| 42 | |
private IAutoImportView autoImportView; |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
public AcSearchTitles() { |
| 48 | 0 | super("generic.view.actions.search"); |
| 49 | |
|
| 50 | 0 | Managers.getManager(IBeansManager.class).inject(this); |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
@Override |
| 54 | |
public void actionPerformed(ActionEvent arg0) { |
| 55 | 0 | if (autoImportView.validateContent(IAutoImportView.PHASE_1)) { |
| 56 | 0 | Managers.getManager(IViewManager.class).execute(new SimpleTask() { |
| 57 | |
@Override |
| 58 | |
public void run() { |
| 59 | 0 | autoImportView.startWait(); |
| 60 | |
|
| 61 | 0 | new Thread(new SearchTitlesRunnable()).start(); |
| 62 | 0 | } |
| 63 | |
}); |
| 64 | |
} |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | 0 | private final class SearchTitlesRunnable implements Runnable { |
| 73 | |
@Override |
| 74 | |
public void run() { |
| 75 | 0 | Managers.getManager(IViewManager.class).execute(new SimpleTask() { |
| 76 | |
@Override |
| 77 | |
public void run() { |
| 78 | 0 | autoImportView.getModelTitles().clear(); |
| 79 | 0 | } |
| 80 | |
}); |
| 81 | |
|
| 82 | 0 | final Collection<String> titles = service.getFilmTitles(new File(autoImportView.getFolderPath()), autoImportView.isFileMode()); |
| 83 | |
|
| 84 | 0 | for (final String title : titles) { |
| 85 | 0 | Managers.getManager(IViewManager.class).execute(new SimpleTask() { |
| 86 | |
@Override |
| 87 | |
public void run() { |
| 88 | 0 | autoImportView.getModelTitles().addElement(title); |
| 89 | 0 | } |
| 90 | |
}); |
| 91 | |
} |
| 92 | |
|
| 93 | 0 | Managers.getManager(IViewManager.class).execute(new SimpleTask() { |
| 94 | |
@Override |
| 95 | |
public void run() { |
| 96 | 0 | autoImportView.getModel().setTitles(titles); |
| 97 | 0 | autoImportView.stopWait(); |
| 98 | 0 | } |
| 99 | |
}); |
| 100 | 0 | } |
| 101 | |
} |
| 102 | |
} |