svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / export / swing / impl / panels / ExportProgressPanel.java @ 44497
History | View | Annotate | Download (4.11 KB)
1 | 43925 | jjdelcerro | package org.gvsig.export.swing.impl.panels; |
---|---|---|---|
2 | |||
3 | import java.awt.BorderLayout; |
||
4 | 44386 | omartinez | import java.awt.event.ActionEvent; |
5 | import java.awt.event.ActionListener; |
||
6 | 44395 | omartinez | import java.util.Date; |
7 | 43925 | jjdelcerro | import javax.swing.JComponent; |
8 | 44386 | omartinez | import org.gvsig.export.ExportLocator; |
9 | 43925 | jjdelcerro | import org.gvsig.export.ExportParameters; |
10 | import org.gvsig.export.swing.JExportProcessPanel; |
||
11 | import org.gvsig.export.swing.spi.ExportPanel; |
||
12 | import org.gvsig.export.swing.spi.ExportPanelValidationException; |
||
13 | import org.gvsig.tools.ToolsLocator; |
||
14 | 44386 | omartinez | import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
15 | 43925 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
16 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
17 | 44395 | omartinez | import org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue; |
18 | 44386 | omartinez | import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
19 | 44390 | jjdelcerro | import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController.BookmarkEvent; |
20 | 43925 | jjdelcerro | import org.gvsig.tools.swing.api.task.JTaskStatus; |
21 | import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
||
22 | 44390 | jjdelcerro | import org.slf4j.Logger; |
23 | import org.slf4j.LoggerFactory; |
||
24 | 43925 | jjdelcerro | |
25 | /**
|
||
26 | *
|
||
27 | * @author jjdelcerro
|
||
28 | */
|
||
29 | 44386 | omartinez | public class ExportProgressPanel |
30 | extends ExportProgressPanelView
|
||
31 | implements ExportPanel {
|
||
32 | 43925 | jjdelcerro | |
33 | 44390 | jjdelcerro | private final static Logger LOGGER = LoggerFactory.getLogger(ExportProgressPanel.class); |
34 | 44395 | omartinez | |
35 | 43925 | jjdelcerro | private final JExportProcessPanel processPanel; |
36 | private final ExportParameters parameters; |
||
37 | private JTaskStatus jTaskStatus;
|
||
38 | 44386 | omartinez | private BookmarksController bookmarksController;
|
39 | |||
40 | 43925 | jjdelcerro | public ExportProgressPanel(
|
41 | JExportProcessPanel processPanel, |
||
42 | ExportParameters parameters |
||
43 | 44386 | omartinez | ) { |
44 | 43925 | jjdelcerro | this.processPanel = processPanel;
|
45 | this.parameters = parameters;
|
||
46 | this.initComponents();
|
||
47 | } |
||
48 | 44386 | omartinez | |
49 | 43925 | jjdelcerro | private void initComponents() { |
50 | TaskStatusSwingManager TaskStatusSwingManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
||
51 | |||
52 | this.jTaskStatus = TaskStatusSwingManager.createJTaskStatus();
|
||
53 | 44386 | omartinez | this.jpnMain.setLayout(new BorderLayout()); |
54 | this.jpnMain.add(jTaskStatus, BorderLayout.NORTH); |
||
55 | 43925 | jjdelcerro | this.jTaskStatus.bind(this.processPanel.getProcess().getTaskStatus()); |
56 | 44386 | omartinez | |
57 | 44390 | jjdelcerro | Bookmarks<ExportParameters> bookmarks = ExportLocator.getManager().getBookmarks(); |
58 | 44386 | omartinez | this.bookmarksController = ToolsSwingLocator.getToolsSwingManager().createBookmarksController(bookmarks, this.btnBookmark); |
59 | this.bookmarksController.setAllowAddBookmarks(true); |
||
60 | this.bookmarksController.setFilter(null); |
||
61 | this.bookmarksController.addActionListener(new ActionListener() { |
||
62 | @Override
|
||
63 | public void actionPerformed(ActionEvent e) { |
||
64 | try {
|
||
65 | 44395 | omartinez | if (e.getID() == ActionEventWithCurrentValue.ID_GETVALUE) {
|
66 | BookmarkEvent bookmarkEvent = (BookmarkEvent) e; |
||
67 | ExportParameters clone = parameters.clone(); |
||
68 | clone.setCreationDate(new Date()); |
||
69 | bookmarkEvent.setCurrentValue(clone); |
||
70 | 44386 | omartinez | } |
71 | } catch (CloneNotSupportedException ex) { |
||
72 | 44390 | jjdelcerro | LOGGER.warn("Can't clone export parameters.", ex);
|
73 | 44386 | omartinez | } |
74 | } |
||
75 | }); |
||
76 | 43925 | jjdelcerro | } |
77 | |||
78 | @Override
|
||
79 | public String getIdPanel() { |
||
80 | return "ExportProgressPanel"; |
||
81 | } |
||
82 | 44386 | omartinez | |
83 | 43925 | jjdelcerro | @Override
|
84 | public String getTitlePanel() { |
||
85 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
86 | 44386 | omartinez | return i18nManager.getTranslation("export_progress"); |
87 | 43925 | jjdelcerro | } |
88 | |||
89 | @Override
|
||
90 | public boolean validatePanel() throws ExportPanelValidationException { |
||
91 | return true; |
||
92 | } |
||
93 | |||
94 | @Override
|
||
95 | public void enterPanel() { |
||
96 | 44395 | omartinez | // this.jTaskStatus.setCurValue(0);
|
97 | 43925 | jjdelcerro | |
98 | 43968 | jjdelcerro | } |
99 | |||
100 | @Override
|
||
101 | public void nextPanel() { |
||
102 | 43925 | jjdelcerro | processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_FINISH, false);
|
103 | } |
||
104 | |||
105 | @Override
|
||
106 | 43968 | jjdelcerro | public void previousPanel() { |
107 | processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_FINISH, true);
|
||
108 | processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_CANCEL, true);
|
||
109 | 44468 | omartinez | processPanel.setButtonText(JExportProcessPanel.BUTTON_CANCEL, ToolsLocator.getI18nManager().getTranslation("_Cancel"));
|
110 | 43925 | jjdelcerro | } |
111 | |||
112 | @Override
|
||
113 | public JComponent asJComponent() { |
||
114 | return this; |
||
115 | } |
||
116 | |||
117 | } |