org.homeunix.thecave.buddi.plugin.api
Class BuddiImportPlugin

java.lang.Object
  extended by org.homeunix.thecave.buddi.plugin.api.PreferenceAccess
      extended by org.homeunix.thecave.buddi.plugin.api.MenuPlugin
          extended by org.homeunix.thecave.buddi.plugin.api.BuddiImportPlugin
All Implemented Interfaces:
FileAccess, MossPlugin
Direct Known Subclasses:
ImportTestData

public abstract class BuddiImportPlugin
extends MenuPlugin
implements MossPlugin, FileAccess

The abstract class to extend when creating an import plugin. The method importData() is the one which is called by Buddi when executing the plugin. In this method, you have access to the main document object, the frame from which the plugin was called, and the file to import from.

Author:
wyatt

Constructor Summary
BuddiImportPlugin()
           
 
Method Summary
 java.lang.String getDescription()
          Returns the description for the plugin.
 java.lang.String getProcessingMessage()
          Returns the message which should show when processing the data.
abstract  void importData(MutableDocument model, MossDocumentFrame callingFrame, java.io.File file)
          Imports data as required.
 boolean isCreateNewFile()
          If set to true, we will force the creation of a new file here.
 boolean isFileChooserSave()
          If we show a file chooser, should it be of type 'Save'? If false, it will be of type Open.
 void processData(MutableDocument model, MossDocumentFrame callingFrame, java.io.File file)
          Processes data as required.
 
Methods inherited from class org.homeunix.thecave.buddi.plugin.api.MenuPlugin
getFileExtensions, getMaximumVersion, getMinimumVersion, isPluginActive, isPromptForFile
 
Methods inherited from class org.homeunix.thecave.buddi.plugin.api.PreferenceAccess
getListPreference, getPreference, getSecurePreference, putListPreference, putPreference, putSecurePreference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.homeunix.thecave.moss.plugin.MossPlugin
getMaximumVersion, getMinimumVersion, getName, isPluginActive
 
Methods inherited from interface org.homeunix.thecave.buddi.plugin.api.FileAccess
getFileExtensions, isPromptForFile
 

Constructor Detail

BuddiImportPlugin

public BuddiImportPlugin()
Method Detail

importData

public abstract void importData(MutableDocument model,
                                MossDocumentFrame callingFrame,
                                java.io.File file)
                         throws PluginException,
                                PluginMessage
Imports data as required. The plugin launch code will prompt for a file and pass it in (unless you override the isPromptForFile() method to return false). This method is executed from the launch code within a SwingWorker thread. Once this method is completed, the launch code will update all windows with any new information which may have come from this plugin. Thus, it is not a good idea to use any threads in this method, unless you can guarantee that this method will not complete until all data processing is completed. As well, since this method is not run from the AWT Event thread, you should not display any Swing objects here, as it can potentially cause deadlocks in some situations. This should not be a problem for most plugins, as they just need a file (provided), and that is all. If you do need to display some Swing objects, you can do so using the SwingUtilities.invokeLater() method.

Throws:
PluginException
PluginMessage

processData

public void processData(MutableDocument model,
                        MossDocumentFrame callingFrame,
                        java.io.File file)
                 throws PluginException,
                        PluginMessage
Description copied from class: MenuPlugin
Processes data as required. This method will call one of exportData(), importData(), or synchronizeData(), depending on the plugin type. This method is only included to make it easier to call the plugins from the File menu. Plugin implementors should *not* override this method, as you will get unpredictable results if you do. Instead, override the correct method for your plugin type.

Specified by:
processData in class MenuPlugin
Throws:
PluginException
PluginMessage

getDescription

public java.lang.String getDescription()
Description copied from class: MenuPlugin
Returns the description for the plugin. This is used in the File Chooser, as the name for the file filter.

Specified by:
getDescription in interface FileAccess
Specified by:
getDescription in interface MossPlugin
Specified by:
getDescription in class MenuPlugin
Returns:
See Also:
MossPlugin.getDescription()

getProcessingMessage

public java.lang.String getProcessingMessage()
Description copied from interface: FileAccess
Returns the message which should show when processing the data. Defaults to "Processing File..."; override if needed. This value is filtered through the translator before being displayed.

Specified by:
getProcessingMessage in interface FileAccess
Returns:

isFileChooserSave

public boolean isFileChooserSave()
Description copied from class: MenuPlugin
If we show a file chooser, should it be of type 'Save'? If false, it will be of type Open. This method is meant to be implemented in the Buddi*Plugin classes; plugin authors: do not implement this unless you are POSITIVE that you know exactly what you are doing. Also be aware that this method may be subject to change in future versions without any notice.

Specified by:
isFileChooserSave in class MenuPlugin
Returns:

isCreateNewFile

public boolean isCreateNewFile()
If set to true, we will force the creation of a new file here. Most people will want to leave this as false (the default); only people who are importing a complete file from another source (e.g. Legacy Buddi files) will want to set it to true.

Returns: