| 1 | |
package org.jtheque.films.view.impl.frames; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
import org.jtheque.core.managers.error.JThequeError; |
| 20 | |
import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel; |
| 21 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView; |
| 22 | |
import org.jtheque.core.utils.ui.Borders; |
| 23 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
| 24 | |
import org.jtheque.core.utils.ui.ValidationUtils; |
| 25 | |
import org.jtheque.films.persistence.od.able.Film; |
| 26 | |
import org.jtheque.films.services.impl.utils.search.Searcher; |
| 27 | |
import org.jtheque.films.view.able.IExportView; |
| 28 | |
import org.jtheque.films.view.impl.actions.CloseViewAction; |
| 29 | |
import org.jtheque.films.view.impl.actions.file.AcValidateExportView; |
| 30 | |
import org.jtheque.films.view.impl.panels.search.JPanelFilmSearch; |
| 31 | |
import org.jtheque.utils.io.SimpleFilter; |
| 32 | |
import org.jtheque.utils.ui.GridBagUtils; |
| 33 | |
|
| 34 | |
import java.awt.Color; |
| 35 | |
import java.awt.Container; |
| 36 | |
import java.awt.Frame; |
| 37 | |
import java.util.Collection; |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
public final class ExportView extends SwingDialogView implements IExportView { |
| 45 | |
private static final long serialVersionUID = -1591189533123010866L; |
| 46 | |
|
| 47 | |
private FileChooserPanel chooser; |
| 48 | |
private JPanelFilmSearch searchPanel; |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public ExportView(Frame parent) { |
| 56 | 0 | super(parent); |
| 57 | |
|
| 58 | 0 | build(); |
| 59 | 0 | } |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
private void build() { |
| 65 | 0 | setTitleKey("export.view.title"); |
| 66 | 0 | setContentPane(buildContentPane()); |
| 67 | |
|
| 68 | 0 | pack(); |
| 69 | 0 | setLocationRelativeTo(getOwner()); |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
private Container buildContentPane() { |
| 78 | 0 | PanelBuilder builder = new PanelBuilder(); |
| 79 | |
|
| 80 | 0 | chooser = new FileChooserPanel(); |
| 81 | 0 | chooser.setTextKey("export.view.filePath"); |
| 82 | 0 | chooser.setBackground(Color.white); |
| 83 | 0 | builder.add(chooser, builder.gbcSet(0, 0)); |
| 84 | |
|
| 85 | 0 | searchPanel = new JPanelFilmSearch(); |
| 86 | 0 | searchPanel.setBorder(Borders.createTitledBorder("export.view.search")); |
| 87 | 0 | builder.add(searchPanel, builder.gbcSet(0, 1, GridBagUtils.BOTH)); |
| 88 | |
|
| 89 | 0 | builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL), |
| 90 | |
new AcValidateExportView(), new CloseViewAction("generic.view.actions.cancel", this)); |
| 91 | |
|
| 92 | 0 | return builder.getPanel(); |
| 93 | |
} |
| 94 | |
|
| 95 | |
@Override |
| 96 | |
public Searcher<Film> getSearcher() { |
| 97 | 0 | return searchPanel.getSearcher(); |
| 98 | |
} |
| 99 | |
|
| 100 | |
@Override |
| 101 | |
public String getFilePath() { |
| 102 | 0 | return chooser.getFilePath(); |
| 103 | |
} |
| 104 | |
|
| 105 | |
@Override |
| 106 | |
public void sendMessage(String message, Object value) { |
| 107 | 0 | if ("filter".equals(message)) { |
| 108 | 0 | chooser.setFileFilter((SimpleFilter) value); |
| 109 | |
} |
| 110 | 0 | } |
| 111 | |
|
| 112 | |
@Override |
| 113 | |
protected void validate(Collection<JThequeError> errors) { |
| 114 | 0 | ValidationUtils.rejectIfEmpty(getFilePath(), "export.view.filePath", errors); |
| 115 | 0 | } |
| 116 | |
} |