com.extentech.ExtenXLS.eventui.swing
Class ExtenXLSFileHandler

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

public class ExtenXLSFileHandler
extends java.lang.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(java.io.File source, java.io.File target)
          Copy method, using FileChannel#transferTo NOTE: will overwrite existing files
static boolean copyAskOverwrite(java.lang.String sourcefName, java.lang.String targetfName)
           
 java.lang.String getRDFName()
           
static java.lang.String getRelativePath(java.lang.String fname, java.lang.String dir)
          Utility to strip a file path of a specific directory, leaving the relative directory intact
 java.lang.String getRelativeRDFPath()
          Returns the path relative to the working directory from the current rdfname
 XMLBeanNode getRootNode()
           
 java.lang.String getTemplateNameFromRoot()
           
static java.lang.String getWorkingDir()
           
 boolean initRootNode(boolean newrpt)
          Takes rdfname with fully qualified path and creates a DataObject
 java.lang.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!).
 java.lang.String openRDFFile()
          Allows choosing of an existing DOML Filename.
 java.lang.String openRDFFileX()
          Allows choosing of an existing DOML Filename WITHOUT working directory limitations Sets rdfname with fully qualified doml filename or "" if error/cancel
 java.lang.String openXLSFile()
          allows selection of an existing XLS filename WITHOUT working directory restrictions
 java.lang.String openXLSFile(byte OpenType)
          Retrieves an XLS file either from disk (OpenType=CHOOSEEXISTINGXLS) or creates a new XLS file from template (OpenType=CREATEFROMTEMPLATE).
static java.nio.ByteBuffer readFile(java.lang.String fpath)
          read in bytes from a file path.
 void reportError(java.lang.String errMsg, java.lang.String title)
          Fairly Generic Error Reporting
 void setParent(java.awt.Container parent)
           
 boolean setRDFName(java.lang.String rdfname)
          allows setting of an (existing) rdfname.
 void setWorkingDirectory(java.lang.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(java.awt.Container parent)

getRootNode

public XMLBeanNode getRootNode()

openFromServer

public java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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(java.lang.String wdir)

setRDFName

public boolean setRDFName(java.lang.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 java.lang.String getRelativeRDFPath()
Returns the path relative to the working directory from the current rdfname

Returns:
relative path

getRDFName

public java.lang.String getRDFName()

getTemplateNameFromRoot

public java.lang.String getTemplateNameFromRoot()

getRelativePath

public static java.lang.String getRelativePath(java.lang.String fname,
                                               java.lang.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 java.lang.String getWorkingDir()

copy

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

Parameters:
File - source
File - target
Throws:
java.io.IOException

copyAskOverwrite

public static boolean copyAskOverwrite(java.lang.String sourcefName,
                                       java.lang.String targetfName)
                                throws java.io.IOException
Throws:
java.io.IOException

readFile

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

Parameters:
fpath -
Returns:
Memory-mapped ByteBuffer
Throws:
java.io.IOException

reportError

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

Parameters:
errMsg -
title -


Copyright © 2011 Extentech Inc. All Rights Reserved.