Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BuddiExportPlugin |
|
| 1.0;1 |
1 | /* | |
2 | * Created on Sep 14, 2006 by wyatt | |
3 | * | |
4 | * The interface which can be extended to create export files | |
5 | */ | |
6 | package org.homeunix.thecave.buddi.plugin.api; | |
7 | ||
8 | import java.io.File; | |
9 | ||
10 | import org.homeunix.thecave.buddi.i18n.BuddiKeys; | |
11 | import org.homeunix.thecave.buddi.plugin.api.exception.PluginException; | |
12 | import org.homeunix.thecave.buddi.plugin.api.exception.PluginMessage; | |
13 | import org.homeunix.thecave.buddi.plugin.api.model.ImmutableDocument; | |
14 | import org.homeunix.thecave.buddi.plugin.api.model.MutableDocument; | |
15 | ||
16 | import ca.digitalcave.moss.application.plugin.MossPlugin; | |
17 | import ca.digitalcave.moss.swing.MossDocumentFrame; | |
18 | ||
19 | /** | |
20 | * The abstract class to extend when creating an export plugin. The method exportData() | |
21 | * is the one which is called by Buddi when executing the plugin. In this method, | |
22 | * you have access to the main document object, the frame from which the plugin was | |
23 | * called, and the file to export to. | |
24 | * | |
25 | * @author wyatt | |
26 | * | |
27 | */ | |
28 | 0 | public abstract class BuddiExportPlugin extends MenuPlugin implements MossPlugin, FileAccess { |
29 | ||
30 | /** | |
31 | * Exports data as required. The plugin launch code will prompt for a file | |
32 | * and pass it in (unless you override the isPromptForFile() method to return false). | |
33 | * | |
34 | * This method is executed from the launch code within a SwingWorker thread. Once this | |
35 | * method is completed, the launch code will update all windows with any new information | |
36 | * which may have come from this plugin. Thus, it is not a good idea to use any threads | |
37 | * in this method, unless you can guarantee that this method will not complete until | |
38 | * all data processing is completed. | |
39 | * | |
40 | * As well, since this method is not run from the AWT Event thread, you should not display | |
41 | * any Swing objects here, as it can potentially cause deadlocks in some situations. This | |
42 | * should not be a problem for most plugins, as they just need a file (provided), and that is | |
43 | * all. If you do need to display some Swing objects, you can do so using the | |
44 | * SwingUtilities.invokeLater() method. | |
45 | */ | |
46 | public abstract void exportData(ImmutableDocument model, MossDocumentFrame callingFrame, File file) throws PluginException, PluginMessage; | |
47 | ||
48 | @Override | |
49 | public void processData(MutableDocument model, MossDocumentFrame callingFrame, File file) throws PluginException, PluginMessage { | |
50 | 0 | exportData(model, callingFrame, file); |
51 | 0 | } |
52 | ||
53 | public String getDescription() { | |
54 | 0 | return BuddiKeys.FILE_DESCRIPTION_BUDDI_EXPORT_FILES.toString(); |
55 | } | |
56 | ||
57 | public String getProcessingMessage() { | |
58 | 0 | return BuddiKeys.MESSAGE_EXPORTING_FILE.toString(); |
59 | } | |
60 | ||
61 | @Override | |
62 | public boolean isFileChooserSave() { | |
63 | 0 | return true; |
64 | } | |
65 | } |