| 1 | |
package org.jtheque.films.view.impl.frames; |
| 2 | |
|
| 3 | |
import org.jtheque.core.managers.error.JThequeError; |
| 4 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView; |
| 5 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
| 6 | |
import org.jtheque.films.services.impl.utils.VideoFile; |
| 7 | |
import org.jtheque.films.view.able.IVideoView; |
| 8 | |
import org.jtheque.films.view.impl.actions.CloseViewAction; |
| 9 | |
import org.jtheque.films.view.impl.actions.video.AcNewVideoFile; |
| 10 | |
import org.jtheque.films.view.impl.actions.video.AcOpenVideoFile; |
| 11 | |
import org.jtheque.films.view.impl.actions.video.AcRefreshVideoView; |
| 12 | |
import org.jtheque.films.view.impl.models.list.VideoListModel; |
| 13 | |
import org.jtheque.films.view.impl.renderers.VideoListRenderer; |
| 14 | |
import org.jtheque.utils.ui.GridBagUtils; |
| 15 | |
|
| 16 | |
import javax.swing.JList; |
| 17 | |
import javax.swing.ListSelectionModel; |
| 18 | |
import java.awt.Container; |
| 19 | |
import java.awt.Frame; |
| 20 | |
import java.util.Collection; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
public final class VideoView extends SwingDialogView implements IVideoView { |
| 44 | |
private JList list; |
| 45 | |
|
| 46 | |
private final VideoListModel model; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public VideoView(Frame parent) { |
| 54 | 0 | super(parent); |
| 55 | |
|
| 56 | 0 | model = new VideoListModel(); |
| 57 | |
|
| 58 | 0 | setTitleKey("video.view.title"); |
| 59 | 0 | setContentPane(buildContentPane()); |
| 60 | 0 | pack(); |
| 61 | |
|
| 62 | 0 | setLocationRelativeTo(getOwner()); |
| 63 | 0 | } |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
private Container buildContentPane() { |
| 71 | 0 | PanelBuilder builder = new PanelBuilder(); |
| 72 | |
|
| 73 | 0 | list = new JList(); |
| 74 | 0 | list.setModel(model); |
| 75 | 0 | list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 76 | 0 | list.setCellRenderer(new VideoListRenderer()); |
| 77 | 0 | list.setVisibleRowCount(4); |
| 78 | |
|
| 79 | 0 | builder.addScrolled(list, builder.gbcSet(0, 0, GridBagUtils.BOTH, GridBagUtils.ABOVE_BASELINE_LEADING, 0, -1, 1.0, 1.0)); |
| 80 | |
|
| 81 | 0 | builder.addButtonBar(builder.gbcSet(0, 1, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 0.0), |
| 82 | |
new AcRefreshVideoView(), new AcOpenVideoFile(), new AcNewVideoFile(), new CloseViewAction("generic.view.actions.cancel", this)); |
| 83 | |
|
| 84 | 0 | return builder.getPanel(); |
| 85 | |
} |
| 86 | |
|
| 87 | |
@Override |
| 88 | |
protected void validate(Collection<JThequeError> errors) { |
| 89 | 0 | } |
| 90 | |
|
| 91 | |
@Override |
| 92 | |
public VideoFile getSelectedFile() { |
| 93 | 0 | return (VideoFile) list.getSelectedValue(); |
| 94 | |
} |
| 95 | |
|
| 96 | |
@Override |
| 97 | |
public void refreshList() { |
| 98 | 0 | model.refresh(); |
| 99 | 0 | } |
| 100 | |
} |