| 1 | |
package org.jtheque.films.view.impl.panels; |
| 2 | |
|
| 3 | |
import org.jtheque.core.managers.error.JThequeError; |
| 4 | |
import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel; |
| 5 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
| 6 | |
import org.jtheque.core.utils.ui.constraints.ConstraintManager; |
| 7 | |
import org.jtheque.films.persistence.od.able.Film; |
| 8 | |
import org.jtheque.films.utils.Constants.Properties; |
| 9 | |
import org.jtheque.films.view.able.IInfosOthersView; |
| 10 | |
import org.jtheque.films.view.impl.fb.IFilmFormBean; |
| 11 | |
import org.jtheque.primary.view.impl.listeners.ObjectChangedEvent; |
| 12 | |
import org.jtheque.utils.ui.GridBagUtils; |
| 13 | |
|
| 14 | |
import javax.annotation.PostConstruct; |
| 15 | |
import javax.swing.JComponent; |
| 16 | |
import javax.swing.JPanel; |
| 17 | |
import java.util.Collection; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | 0 | public final class JPanelInfosOthers extends JPanel implements IInfosOthersView { |
| 41 | |
private FileChooserPanel fieldFile; |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
@PostConstruct |
| 47 | |
private void build() { |
| 48 | 0 | PanelBuilder builder = new PanelBuilder(this); |
| 49 | |
|
| 50 | 0 | fieldFile = new FileChooserPanel(); |
| 51 | 0 | fieldFile.setTextKey(Properties.Film.FILE_PATH); |
| 52 | |
|
| 53 | 0 | builder.add(fieldFile, builder.gbcSet(0, 0, GridBagUtils.BOTH, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 1.0)); |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
@Override |
| 57 | |
public void objectChanged(ObjectChangedEvent event) { |
| 58 | 0 | Film film = (Film) event.getObject(); |
| 59 | |
|
| 60 | 0 | fieldFile.setFilePath(film.getFilePath()); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
@Override |
| 69 | |
public void fillFilm(IFilmFormBean fb) { |
| 70 | 0 | fb.setFilePath(fieldFile.getFilePath()); |
| 71 | 0 | } |
| 72 | |
|
| 73 | |
@Override |
| 74 | |
public void setEnabled(boolean enabled) { |
| 75 | 0 | fieldFile.setEnabled(enabled); |
| 76 | |
|
| 77 | 0 | super.setEnabled(enabled); |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
@Override |
| 86 | |
public void validate(Collection<JThequeError> errors) { |
| 87 | 0 | ConstraintManager.validate(Properties.Film.FILE_PATH, fieldFile.getFilePath(), errors); |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
@Override |
| 91 | |
public JComponent getImpl() { |
| 92 | 0 | return this; |
| 93 | |
} |
| 94 | |
} |