/**
* put out the tree information to XML file <br>
* @return if wrong return 0,else return 1
* @throws N/A
* @author tianrenliang
* @since V0.1(2007/12/06)
*/
public int saveTreeToXmlFile(ViewMsgTree viewMsgTree, String strName)
{
if (viewMsgTree == null )
{
return 0 ;
}
ViewMsgTreeItem rootItem = viewMsgTree.getRootItem();
ITreeNode treenode = rootItem.getRefNode(); // get the root node
// strFileName = ViewTreeList.getInstance().getCurrentSelPduName();
/* create a save dialog,create a xml file by using this dialog : Start */
Shell sMain = MainWindow.getInstance().openMainWindow();
if ( null == sMain)
{
return 0 ;
}
FileDialog fileDlg = new FileDialog(sMain, SWT.SAVE);
if ( null != strName)
{
fileDlg.setFileName(strName);
}
fileDlg.setFilterExtensions( new String[] { " *.xml " });
// set first time dialog save path
String def = getDefaultPath();
if (xmlFilePath == null )
{
fileDlg.setFilterPath(def);
}
xmlFilePath = fileDlg.open();
// set next open dialog's save path
if ( null != xmlFilePath)
{
fileDlg.setFilterPath(xmlFilePath);
}
else
{
return 0 ;
}
File file = new File(xmlFilePath);
try {
file.createNewFile(); // create a new file to save the out put
} catch (IOException e1) {
OutPutIOException.getInstance().logException(e1);
}
/* create a save dialog,create a xml file by using this dialog : End */
// out put the the tree to the xml file
FileOutputStream fileOut = null ;
// control and manage progressBar
createProgressThred();
if (xmlFilePath != null )
{
XMLOutputter XMLOut = new XMLOutputter(Format.getPrettyFormat());
try {
fileOut = new FileOutputStream(xmlFilePath);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
OutPutIOException.getInstance().logException(e1);
}
try { // out put a tree based on root treenode
XMLOut.output(treenode.parseToXml(),fileOut);
} catch (FileNotFoundException e) {
OutPutIOException.getInstance().logException(e);
} catch (IOException e) {
OutPutIOException.getInstance().logException(e);
}
try {
fileOut.close(); // close the stream
} catch (IOException e) {
OutPutIOException.getInstance().logException(e);
}
}
mainInstance.setStopFlag( true );
return 1 ;
}
* put out the tree information to XML file <br>
* @return if wrong return 0,else return 1
* @throws N/A
* @author tianrenliang
* @since V0.1(2007/12/06)
*/
public int saveTreeToXmlFile(ViewMsgTree viewMsgTree, String strName)
{
if (viewMsgTree == null )
{
return 0 ;
}
ViewMsgTreeItem rootItem = viewMsgTree.getRootItem();
ITreeNode treenode = rootItem.getRefNode(); // get the root node
// strFileName = ViewTreeList.getInstance().getCurrentSelPduName();
/* create a save dialog,create a xml file by using this dialog : Start */
Shell sMain = MainWindow.getInstance().openMainWindow();
if ( null == sMain)
{
return 0 ;
}
FileDialog fileDlg = new FileDialog(sMain, SWT.SAVE);
if ( null != strName)
{
fileDlg.setFileName(strName);
}
fileDlg.setFilterExtensions( new String[] { " *.xml " });
// set first time dialog save path
String def = getDefaultPath();
if (xmlFilePath == null )
{
fileDlg.setFilterPath(def);
}
xmlFilePath = fileDlg.open();
// set next open dialog's save path
if ( null != xmlFilePath)
{
fileDlg.setFilterPath(xmlFilePath);
}
else
{
return 0 ;
}
File file = new File(xmlFilePath);
try {
file.createNewFile(); // create a new file to save the out put
} catch (IOException e1) {
OutPutIOException.getInstance().logException(e1);
}
/* create a save dialog,create a xml file by using this dialog : End */
// out put the the tree to the xml file
FileOutputStream fileOut = null ;
// control and manage progressBar
createProgressThred();
if (xmlFilePath != null )
{
XMLOutputter XMLOut = new XMLOutputter(Format.getPrettyFormat());
try {
fileOut = new FileOutputStream(xmlFilePath);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
OutPutIOException.getInstance().logException(e1);
}
try { // out put a tree based on root treenode
XMLOut.output(treenode.parseToXml(),fileOut);
} catch (FileNotFoundException e) {
OutPutIOException.getInstance().logException(e);
} catch (IOException e) {
OutPutIOException.getInstance().logException(e);
}
try {
fileOut.close(); // close the stream
} catch (IOException e) {
OutPutIOException.getInstance().logException(e);
}
}
mainInstance.setStopFlag( true );
return 1 ;
}