JIDE 3.5.15

com.jidesoft.dashboard
Class DashboardPersistenceUtils

java.lang.Object
  extended by com.jidesoft.dashboard.DashboardPersistenceUtils

public class DashboardPersistenceUtils
extends Object

A helper class that can support persist DashbardHolder to/from xml file.

Please note, for DashboardDocumentPane, you need to extra layout loading and saving in order to restore the dashboard layout correctly.

Here is the saving code.


 DashboardPersistenceUtils.save(_documentPane, chooser.getSelectedFile().getAbsolutePath());
 _documentPane.getLayoutPersistence().saveLayoutData();
 

Here is the loading code.

 DashboardPersistenceUtils.load(_documentPane, the layout file saved by DashboardPersistenceUtils);
 try {
     _documentPane.getGadgetManager().setDisposeGadgetsWhenHidingDashboard(false);
     _documentPane.getLayoutPersistence().loadLayoutData();
 }
 finally {
     _documentPane.getGadgetManager().setDisposeGadgetsWhenHidingDashboard(true);
 }


Constructor Summary
DashboardPersistenceUtils()
           
 
Method Summary
static String getVersion(Document document)
           
static String getVersion(InputStream in)
           
static String getVersion(String fileName)
           
static void internalLoad(DashboardHolder holder, Document document, boolean removeAll, PersistenceUtilsCallback.Load callback)
           
static void load(DashboardHolder holder, Document document)
           
static void load(DashboardHolder holder, Document document, boolean removeAll)
           
static void load(DashboardHolder holder, Document document, boolean removeAll, PersistenceUtilsCallback.Load callback)
          Loads the dashboard from the document.
static void load(DashboardHolder holder, InputStream in)
           
static void load(DashboardHolder holder, InputStream in, boolean removeAll)
           
static void load(DashboardHolder holder, String fileName)
           
static void load(DashboardHolder holder, String fileName, boolean removeAll)
           
static void load(DashboardHolder holder, String fileName, boolean removeAll, PersistenceUtilsCallback.Load callback)
           
static void save(DashboardHolder holder, OutputStream out)
          Saves the Dashboard's layout to an output stream.
static void save(DashboardHolder holder, OutputStream out, String encoding)
          Saves the Dashboard's layout to an output stream.
static void save(DashboardHolder holder, OutputStream out, String encoding, PersistenceUtilsCallback.Save callback)
          Saves the Dashboard's layout to an output stream.
static Document save(DashboardHolder holder, PersistenceUtilsCallback.Save callback)
           
static void save(DashboardHolder holder, String fileName)
          Saves the Dashboard's layout to a file.
static void save(DashboardHolder holder, String fileName, String encoding)
          Saves the Dashboard's layout to a file.
static void save(DashboardHolder holder, String fileName, String encoding, PersistenceUtilsCallback.Save callback)
          Saves the Dashboard's layout to a file.
static Document saveActiveDashboard(DashboardHolder holder)
           
static Document saveActiveDashboard(DashboardHolder holder, PersistenceUtilsCallback.Save callback)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, OutputStream out)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, OutputStream out, String encoding)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, OutputStream out, String encoding, PersistenceUtilsCallback.Save callback)
           
static Document saveDashboard(DashboardHolder holder, Dashboard dashboard, PersistenceUtilsCallback.Save callback)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, String fileName)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, String fileName, String encoding)
           
static void saveDashboard(DashboardHolder holder, Dashboard dashboard, String fileName, String encoding, PersistenceUtilsCallback.Save callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DashboardPersistenceUtils

public DashboardPersistenceUtils()
Method Detail

save

public static void save(DashboardHolder holder,
                        String fileName)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to a file.

Parameters:
holder - the dashboard holder
fileName - the file name
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(DashboardHolder holder,
                        String fileName,
                        String encoding)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to a file.

Parameters:
holder - the dashboard holder
fileName - the file name
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(DashboardHolder holder,
                        String fileName,
                        String encoding,
                        PersistenceUtilsCallback.Save callback)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to a file.

Parameters:
holder - the dashboard holder
fileName - the file name
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(DashboardHolder holder,
                        OutputStream out)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to an output stream.

Parameters:
holder - the dashboard holder
out - the output stream
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(DashboardHolder holder,
                        OutputStream out,
                        String encoding)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to an output stream.

Parameters:
holder - the dashboard holder
out - the output stream
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(DashboardHolder holder,
                        OutputStream out,
                        String encoding,
                        PersistenceUtilsCallback.Save callback)
                 throws ParserConfigurationException,
                        IOException
Saves the Dashboard's layout to an output stream.

Parameters:
holder - the dashboard holder
out - the output stream
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
callback - the callback which will be called when saving each element to the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static Document save(DashboardHolder holder,
                            PersistenceUtilsCallback.Save callback)
                     throws ParserConfigurationException
Throws:
ParserConfigurationException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 String fileName)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 OutputStream out)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 String fileName,
                                 String encoding)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 String fileName,
                                 String encoding,
                                 PersistenceUtilsCallback.Save callback)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 OutputStream out,
                                 String encoding)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveDashboard

public static void saveDashboard(DashboardHolder holder,
                                 Dashboard dashboard,
                                 OutputStream out,
                                 String encoding,
                                 PersistenceUtilsCallback.Save callback)
                          throws ParserConfigurationException,
                                 IOException
Throws:
ParserConfigurationException
IOException

saveActiveDashboard

public static Document saveActiveDashboard(DashboardHolder holder)
                                    throws ParserConfigurationException
Throws:
ParserConfigurationException

saveActiveDashboard

public static Document saveActiveDashboard(DashboardHolder holder,
                                           PersistenceUtilsCallback.Save callback)
                                    throws ParserConfigurationException
Throws:
ParserConfigurationException

saveDashboard

public static Document saveDashboard(DashboardHolder holder,
                                     Dashboard dashboard,
                                     PersistenceUtilsCallback.Save callback)
                              throws ParserConfigurationException
Throws:
ParserConfigurationException

load

public static void load(DashboardHolder holder,
                        InputStream in)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(DashboardHolder holder,
                        InputStream in,
                        boolean removeAll)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(DashboardHolder holder,
                        String fileName)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(DashboardHolder holder,
                        String fileName,
                        boolean removeAll)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(DashboardHolder holder,
                        String fileName,
                        boolean removeAll,
                        PersistenceUtilsCallback.Load callback)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(DashboardHolder holder,
                        Document document)

load

public static void load(DashboardHolder holder,
                        Document document,
                        boolean removeAll)

load

public static void load(DashboardHolder holder,
                        Document document,
                        boolean removeAll,
                        PersistenceUtilsCallback.Load callback)
Loads the dashboard from the document.

Parameters:
holder - the DashboardHolder
document - the document to be loaded
removeAll - true to remove all dashboards before loading. False to keep the existing dashboard.

internalLoad

public static void internalLoad(DashboardHolder holder,
                                Document document,
                                boolean removeAll,
                                PersistenceUtilsCallback.Load callback)

getVersion

public static String getVersion(InputStream in)
                         throws ParserConfigurationException,
                                SAXException,
                                IOException
Throws:
ParserConfigurationException
SAXException
IOException

getVersion

public static String getVersion(String fileName)
                         throws ParserConfigurationException,
                                SAXException,
                                IOException
Throws:
ParserConfigurationException
SAXException
IOException

getVersion

public static String getVersion(Document document)

JIDE 3.5.15