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 |
package org.gvsig.export.swing.impl.panels; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.util.Date; |
7 |
import javax.swing.JComponent; |
8 |
import org.gvsig.export.ExportLocator; |
9 |
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 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
15 |
import org.gvsig.tools.i18n.I18nManager; |
16 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
17 |
import org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue; |
18 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
19 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController.BookmarkEvent; |
20 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
21 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
22 |
import org.slf4j.Logger; |
23 |
import org.slf4j.LoggerFactory; |
24 |
|
25 |
/**
|
26 |
*
|
27 |
* @author jjdelcerro
|
28 |
*/
|
29 |
public class ExportProgressPanel |
30 |
extends ExportProgressPanelView
|
31 |
implements ExportPanel {
|
32 |
|
33 |
private final static Logger LOGGER = LoggerFactory.getLogger(ExportProgressPanel.class); |
34 |
|
35 |
private final JExportProcessPanel processPanel; |
36 |
private final ExportParameters parameters; |
37 |
private JTaskStatus jTaskStatus;
|
38 |
private BookmarksController bookmarksController;
|
39 |
|
40 |
public ExportProgressPanel(
|
41 |
JExportProcessPanel processPanel, |
42 |
ExportParameters parameters |
43 |
) { |
44 |
this.processPanel = processPanel;
|
45 |
this.parameters = parameters;
|
46 |
this.initComponents();
|
47 |
} |
48 |
|
49 |
private void initComponents() { |
50 |
TaskStatusSwingManager TaskStatusSwingManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
51 |
|
52 |
this.jTaskStatus = TaskStatusSwingManager.createJTaskStatus();
|
53 |
this.jpnMain.setLayout(new BorderLayout()); |
54 |
this.jpnMain.add(jTaskStatus, BorderLayout.NORTH); |
55 |
this.jTaskStatus.bind(this.processPanel.getProcess().getTaskStatus()); |
56 |
|
57 |
Bookmarks<ExportParameters> bookmarks = ExportLocator.getManager().getBookmarks(); |
58 |
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 |
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 |
} |
71 |
} catch (CloneNotSupportedException ex) { |
72 |
LOGGER.warn("Can't clone export parameters.", ex);
|
73 |
} |
74 |
} |
75 |
}); |
76 |
} |
77 |
|
78 |
@Override
|
79 |
public String getIdPanel() { |
80 |
return "ExportProgressPanel"; |
81 |
} |
82 |
|
83 |
@Override
|
84 |
public String getTitlePanel() { |
85 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
86 |
return i18nManager.getTranslation("export_progress"); |
87 |
} |
88 |
|
89 |
@Override
|
90 |
public boolean validatePanel() throws ExportPanelValidationException { |
91 |
return true; |
92 |
} |
93 |
|
94 |
@Override
|
95 |
public void enterPanel() { |
96 |
// this.jTaskStatus.setCurValue(0);
|
97 |
|
98 |
} |
99 |
|
100 |
@Override
|
101 |
public void nextPanel() { |
102 |
processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_FINISH, false);
|
103 |
} |
104 |
|
105 |
@Override
|
106 |
public void previousPanel() { |
107 |
processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_FINISH, true);
|
108 |
processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_CANCEL, true);
|
109 |
processPanel.setButtonText(JExportProcessPanel.BUTTON_CANCEL, ToolsLocator.getI18nManager().getTranslation("_Cancel"));
|
110 |
} |
111 |
|
112 |
@Override
|
113 |
public JComponent asJComponent() { |
114 |
return this; |
115 |
} |
116 |
|
117 |
} |