com.extentech.ExtenXLS.ui.swing
Class ExtenXLSFileHandler

java.lang.Object
  extended by com.extentech.ExtenXLS.ui.swing.ExtenXLSFileHandler

public class ExtenXLSFileHandler
extends Object

Governs all XLS/DOML file choosing and template operations

Author:
kaia
See Also:
WizardPanel1, WizardPanel3

Field Summary
static byte CHOOSEEXISTINGXLS
           
static byte CREATEFROMTEMPLATE
           
static byte OPENEXISTINGRDF
           
 
Constructor Summary
ExtenXLSFileHandler()
          Default constructor retrieves resources from ExtenXLSMapperWizard.properties file
 
Method Summary
static boolean copy(File source, File target)
          Copy method, using FileChannel#transferTo NOTE: will overwrite existing files
static boolean copyAskOverwrite(String sourcefName, String targetfName)
           
 String getRDFName()
           
static String getRelativePath(String fname, String dir)
          Utility to strip a file path of a specific directory, leaving the relative directory intact
 String getRelativeRDFPath()
          Returns the path relative to the working directory from the current rdfname
 XMLBeanNode getRootNode()
           
 String getTemplateNameFromRoot()
           
static String getWorkingDir()
           
 boolean initRootNode(boolean newrpt)
          Takes rdfname with fully qualified path and creates a DataObject
 String openFromServer()
          Popups up a list of stored templates for the user (will prompt for a user name and password if none have already been defined) and allows selection from the list If selection is successful, will retrieve the XML bytes from the server and write the converted XLS to a temporary file (few!).
 String openRDFFile()
          Allows choosing of an existing DOML Filename.
 String openRDFFileX()
          Allows choosing of an existing DOML Filename WITHOUT working directory limitations Sets rdfname with fully qualified doml filename or "" if error/cancel
 String openXLSFile()
          allows selection of an existing XLS filename WITHOUT working directory restrictions
 String openXLSFile(byte OpenType)
          Retrieves an XLS file either from disk (OpenType=CHOOSEEXISTINGXLS) or creates a new XLS file from template (OpenType=CREATEFROMTEMPLATE).
static ByteBuffer readFile(String fpath)
          read in bytes from a file path.
 void reportError(String errMsg, String title)
          Fairly Generic Error Reporting
 void setParent(Container parent)
           
 boolean setRDFName(String rdfname)
          allows setting of an (existing) rdfname.
 void setWorkingDirectory(String wdir)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATEFROMTEMPLATE

public static final byte CREATEFROMTEMPLATE
See Also:
Constant Field Values

CHOOSEEXISTINGXLS

public static final byte CHOOSEEXISTINGXLS
See Also:
Constant Field Values

OPENEXISTINGRDF

public static final byte OPENEXISTINGRDF
See Also:
Constant Field Values
Constructor Detail

ExtenXLSFileHandler

public ExtenXLSFileHandler()
Default constructor retrieves resources from ExtenXLSMapperWizard.properties file

Method Detail

setParent

public void setParent(Container parent)

getRootNode

public XMLBeanNode getRootNode()

openFromServer

public String openFromServer()
Popups up a list of stored templates for the user (will prompt for a user name and password if none have already been defined) and allows selection from the list If selection is successful, will retrieve the XML bytes from the server and write the converted XLS to a temporary file (few!). The name of this temporary file is returned The listCommand and pullCommand are obtained from extenxlsmapperwizard.properties The listCommand takes as query string parameters username and password, and returns info in memeid/description/owner format The pullCommand takes a meme_id parameter and returns XML template

Returns:
String filename of temporary XLS file

openXLSFile

public String openXLSFile()
allows selection of an existing XLS filename WITHOUT working directory restrictions

Returns:
Fully qualified XLS filename, or "" if cancel was chosen

openXLSFile

public String openXLSFile(byte OpenType)
Retrieves an XLS file either from disk (OpenType=CHOOSEEXISTINGXLS) or creates a new XLS file from template (OpenType=CREATEFROMTEMPLATE). Sets rdfname with fully qualified doml filename (guaranteed to be located under working directory) or "" if error/cancel

Note rdfName is XLS file name with .DOML extension.

Parameters:
byte - OpenType, one of the predefined ExtenXLSFileHandler Open Types
Returns:
String rdfname

openRDFFileX

public String openRDFFileX()
Allows choosing of an existing DOML Filename WITHOUT working directory limitations Sets rdfname with fully qualified doml filename or "" if error/cancel

Returns:
rdfname fully qualified path

openRDFFile

public String openRDFFile()
Allows choosing of an existing DOML Filename. Sets rdfname with fully qualified doml filename (guaranteed to be located under working directory) or "" if error/cancel

Returns:
rdfname

setWorkingDirectory

public void setWorkingDirectory(String wdir)

setRDFName

public boolean setRDFName(String rdfname)
allows setting of an (existing) rdfname.


initRootNode

public boolean initRootNode(boolean newrpt)
Takes rdfname with fully qualified path and creates a DataObject

Parameters:
newrpt - truth of "DOML file has not been created yet"
Returns:
truth of "rootnode was initialized" i.e. success

getRelativeRDFPath

public String getRelativeRDFPath()
Returns the path relative to the working directory from the current rdfname

Returns:
relative path

getRDFName

public String getRDFName()

getTemplateNameFromRoot

public String getTemplateNameFromRoot()

getRelativePath

public static String getRelativePath(String fname,
                                     String dir)
Utility to strip a file path of a specific directory, leaving the relative directory intact

Parameters:
fname - file path
dir - directory to test
Returns:
relative file path

getWorkingDir

public static String getWorkingDir()

copy

public static boolean copy(File source,
                           File target)
                    throws IOException
Copy method, using FileChannel#transferTo NOTE: will overwrite existing files

Parameters:
File - source
File - target
Throws:
IOException

copyAskOverwrite

public static boolean copyAskOverwrite(String sourcefName,
                                       String targetfName)
                                throws IOException
Throws:
IOException

readFile

public static ByteBuffer readFile(String fpath)
                           throws IOException
read in bytes from a file path.

Parameters:
fpath -
Returns:
Memory-mapped ByteBuffer
Throws:
IOException

reportError

public void reportError(String errMsg,
                        String title)
Fairly Generic Error Reporting

Parameters:
errMsg -
title -


Copyright © 2011 Extentech Inc. All Rights Reserved.