LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.control
Class LyExportController

java.lang.Object
  extended by leon.control.LyController
      extended by leon.control.LyAreaController
          extended by leon.control.LyExportController
All Implemented Interfaces:
LyGetSessionInterface, LyContextInterface, LyGetActionInterface, LySelectFileListenerInterface, LyGuiListener, LyInfoListener, LyEvaluator, LyDemandListener, LyAnswerInterface, LyQuestionAnswerInterface
Direct Known Subclasses:
LyMultiClassExportController

public class LyExportController
extends LyAreaController
implements LyQuestionAnswerInterface

This class implements the simple export edition area. The export area is used to create a export of the data into a CSV like text file. This is an ASCII file with separators, one object per line close to the save format of Microsoft Excel. (Excel uses commas or semicolons), as the controller let the user choose these parameters.

Default separators are : FIELD_SEP (for columns) and VALUE_SEP (multiple values) Data may be saved to an ascii file, then retreived with an import controller or an application such as MS Excel

See Also:
LyImportController

Field Summary
static java.lang.String __VERSION
          File Version
static java.lang.String CHARSET
          Form field identifier : select output file path.
static java.lang.String DEMAND_OVERWRITE_FILE
          Application end.
static java.lang.String DEMAND_PREVIEW
          User demand identifier : show preview of saved data.
static java.lang.String EXPORT_SELECTION
          Form field identifier : Checkbox only selected values (default is unchecked).
static java.lang.String FIELD_SEP
          Default field separator in saves.
static java.lang.String PREVIEW_AREA
          Id of the preview area.
static int PREVIEW_HEIGHT
          Preview area height.
static int PREVIEW_WIDTH
          Preview area width.
static java.lang.String SELECT_EXPORT_TYPE
          Form field identifier : export type, either SELECT_EXPORT_TYPE_SPREADSHHET or SELECT_EXPORT_TYPE_TEXT or SELECT_EXPORT_TYPE_RAW or SELECT_EXPORT_TYPE_XML.
static java.lang.String SELECT_EXPORT_TYPE_RAW
          Form field value identifier : export text formated value.
static java.lang.String SELECT_EXPORT_TYPE_SPREADSHEET
          Form field value identifier : export text formated value.
static java.lang.String SELECT_EXPORT_TYPE_TEXT
          Form field value identifier : export text formated value.
static java.lang.String SELECT_EXPORT_TYPE_XML
          Form field value identifier : export text formated value.
static java.lang.String SELECT_FIELD_PREFIX
          Form field identifier
static java.lang.String SELECT_FIELD_RENAME_EXTENSION
          Form field identifier
static java.lang.String SELECT_FIELD_SEP
          Form field identifier : select field separator (default is FIELD_SEP).
static java.lang.String SELECT_FIELDINFOS
          Form field identifier : List of fields that should be saved.
static java.lang.String SELECT_FILE
          Form field identifier : select output file path.
static java.lang.String SELECT_VALUE_SEP
          Form field identifier : select value separator (default is VALUE_SEP).
static java.lang.String SPREADSHEET_FIELD_SEP
          Default field separator in imports.
static java.lang.String SPREADSHEET_VALUE_SEP
          Default multiple value separator in imports.
static java.lang.String VALUE_SEP
          Default multiple value separator in saves.
 
Fields inherited from class leon.control.LyAreaController
DEFAULT_MENU_ITEM_IMAGE_SIZE, DEMAND_APPLY, DEMAND_CANCEL, DEMAND_CLOSE, DEMAND_CREATE_CHART, DEMAND_DELETE_CHART, DEMAND_DELETE_OBJECTINFOS, DEMAND_DELETE_PREFERENCE, DEMAND_UPDATE_VIEW, DEMAND_VALIDATE
 
Fields inherited from class leon.control.LyController
_nbControllers, _nextId, CONTROLLER_ID_SEP, DEFAULT_IMAGE_FORMAT, DEMAND_HELP, ID_SEP
 
Constructor Summary
LyExportController(LySession session, LyController parent, LyAction action, LyClassInfo classInfo, LyObjectList objects)
          Constructor.
 
Method Summary
 void actionDemand(LyActionDemand demand)
          Invoked when an action notification is sent to this listener.
 void export(java.lang.String filePath, java.util.Vector<LyFieldInfo> fields, java.lang.String fieldSep, java.lang.String valueSep, java.lang.String exportType)
          Save the objects to the file.
 java.lang.String exportAsString(java.util.Vector<LyFieldInfo> fields, java.lang.String fieldSep, java.lang.String valueSep, java.lang.String exportType)
          Export the objects as a single string.
 java.lang.Class<?> getBehaviorInterface()
          Method that gives the interface that must be implemented by the behavior associated to this controller.
 LyClassInfo getClassInfo()
          Accessor to the classInfo associated to this form.
 LyObjectList getContent()
          Get content of the chart.
 java.lang.String getExportCharset()
          Accessor to the export charset.
 java.lang.String getExportType()
          Accessor to the export type selected in the GUI.
 java.io.File getFile()
          Accessor to the file.
 java.lang.Object getParameterValue(java.lang.String parameterName)
          Returns the value of a given parameter set on current export action.
 java.lang.String getTemporaryFileName(java.lang.String exportType)
          Access to a temporary file path to store content.
 java.lang.String getTemporaryFileName(java.lang.String exportType, java.lang.String prefix, java.lang.String extension)
          Access to a temporary file path to store content.
 boolean isSilent()
          Checks if this export is in silent mode.
 boolean isViewResizable()
          Indicates if the view for this import controller is resizable.
 void preview(java.util.Vector<LyFieldInfo> fields, java.lang.String fieldSep, java.lang.String valueSep)
          Preview the exported data.
 void questionAnswer(boolean result, java.lang.Object clientData)
          Answer to a askQuestion request.
 void setFile(java.io.File f)
          Accessor to the file.
 void showExportForm()
          Shows the export form.
 void showView()
          Overridden to ensure that export form is displayed.
 
Methods inherited from class leon.control.LyAreaController
canClose, canFree, clearViewCache, completeMenuBar, completeMessages, free, free, getAction, getAreaStackController, getBehavior, getBuilder, getContext, getContextClient, getContextTitle, getDefaultAction, getEnvironment, getFastEditionAction, getHelpFile, getImage, getImageTooltip, getInfoLabel, getInfoLabel, getKeyValue, getLabel, getLastModified, getMenuItemImage, getName, getParameter, getParameter, getParameterMarks, getParent, getParent, getParentAreaController, getRefreshTime, getSelection, getShortLabel, getTarget, getTitle, getViewController, getViewController, hasMark, hasNotMark, hasViewController, hideView, infoEvent, initialize, isInitialized, isOutlined, menuDemand, reset, reset, selectFileDemand, setContext, setContext, setContextClient, setIdle, setPreference, setViewController, showView, testParameter, toString, update, updateTitleBar
 
Methods inherited from class leon.control.LyController
activateViewDemand, demandPerformed, dragDropDemand, getApplication, getClassInfo, getComponent, getId, getImage, getImage, getImage, getImage, getImageFromPrefix, getImageFromPrefix, getImageFromPrefix, getName, getObjectId, getSession, getUserData, getView, getViewManager, helpDemand, hideView, isFreed, isIdle, selectionDemand, setBuilder, setBuilderClass, setLastModified, setName, setUserData, showError, showError, showWarning, updateViewFromValues
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File Version

See Also:
Constant Field Values

DEMAND_OVERWRITE_FILE

public static final java.lang.String DEMAND_OVERWRITE_FILE
Application end.


DEMAND_PREVIEW

public static final java.lang.String DEMAND_PREVIEW
User demand identifier : show preview of saved data.


PREVIEW_AREA

public static final java.lang.String PREVIEW_AREA
Id of the preview area.


PREVIEW_WIDTH

public static final int PREVIEW_WIDTH
Preview area width.

See Also:
Constant Field Values

PREVIEW_HEIGHT

public static final int PREVIEW_HEIGHT
Preview area height.

See Also:
Constant Field Values

SELECT_FIELDINFOS

public static final java.lang.String SELECT_FIELDINFOS
Form field identifier : List of fields that should be saved.


SELECT_EXPORT_TYPE

public static final java.lang.String SELECT_EXPORT_TYPE
Form field identifier : export type, either SELECT_EXPORT_TYPE_SPREADSHHET or SELECT_EXPORT_TYPE_TEXT or SELECT_EXPORT_TYPE_RAW or SELECT_EXPORT_TYPE_XML.


SELECT_EXPORT_TYPE_TEXT

public static final java.lang.String SELECT_EXPORT_TYPE_TEXT
Form field value identifier : export text formated value.


SELECT_EXPORT_TYPE_SPREADSHEET

public static final java.lang.String SELECT_EXPORT_TYPE_SPREADSHEET
Form field value identifier : export text formated value.


SELECT_EXPORT_TYPE_RAW

public static final java.lang.String SELECT_EXPORT_TYPE_RAW
Form field value identifier : export text formated value.


SELECT_EXPORT_TYPE_XML

public static final java.lang.String SELECT_EXPORT_TYPE_XML
Form field value identifier : export text formated value.


SELECT_FIELD_SEP

public static final java.lang.String SELECT_FIELD_SEP
Form field identifier : select field separator (default is FIELD_SEP).


SELECT_VALUE_SEP

public static final java.lang.String SELECT_VALUE_SEP
Form field identifier : select value separator (default is VALUE_SEP).


SELECT_FIELD_PREFIX

public static final java.lang.String SELECT_FIELD_PREFIX
Form field identifier


SELECT_FIELD_RENAME_EXTENSION

public static final java.lang.String SELECT_FIELD_RENAME_EXTENSION
Form field identifier


EXPORT_SELECTION

public static final java.lang.String EXPORT_SELECTION
Form field identifier : Checkbox only selected values (default is unchecked).


SELECT_FILE

public static final java.lang.String SELECT_FILE
Form field identifier : select output file path.


CHARSET

public static final java.lang.String CHARSET
Form field identifier : select output file path.


FIELD_SEP

public static java.lang.String FIELD_SEP
Default field separator in saves.


VALUE_SEP

public static java.lang.String VALUE_SEP
Default multiple value separator in saves.


SPREADSHEET_FIELD_SEP

public static java.lang.String SPREADSHEET_FIELD_SEP
Default field separator in imports.


SPREADSHEET_VALUE_SEP

public static java.lang.String SPREADSHEET_VALUE_SEP
Default multiple value separator in imports.

Constructor Detail

LyExportController

public LyExportController(LySession session,
                          LyController parent,
                          LyAction action,
                          LyClassInfo classInfo,
                          LyObjectList objects)
Constructor.

Parameters:
session - current session associated to the controller. The controller automatically registers on the specified session.
parent - parent controller (or null for 'root' controller).
action - related action. If an action is specified, the controller uses action parameters (action name, action specific XML view description ...)
classInfo - This parameter is used when the objects list contains objects of different classes to known which class is exported.
objects - list of objects that should be saved.
Method Detail

showView

public void showView()
Overridden to ensure that export form is displayed.

Overrides:
showView in class LyAreaController

getBehaviorInterface

public java.lang.Class<?> getBehaviorInterface()
Method that gives the interface that must be implemented by the behavior associated to this controller.

Overrides:
getBehaviorInterface in class LyAreaController
Returns:
Class representing the behavior interface of this controller.

actionDemand

public void actionDemand(LyActionDemand demand)
Invoked when an action notification is sent to this listener.

This method is called by demandPerformed.

At this level, the implementation handles demands of type LyActionDemand.TYPE_ACTION : LyFormController.DEMAND_VALIDATE, LyExportController.DEMAND_PREVIEW, and LyExportController.DEMAND_CANCEL

Overrides:
actionDemand in class LyAreaController
Parameters:
demand - demand parameters sent by the view component.
See Also:
LyController.demandPerformed(leon.view.event.LyDemand)

getParameterValue

public java.lang.Object getParameterValue(java.lang.String parameterName)
Returns the value of a given parameter set on current export action.
The type of the returned value depends on the parameter.

Parameters:
parameterName - the name of the parameter which value must be retrieved.
Returns:
the value of a given parameter set on current export action or null if the parameter is not set on the export action.

getTemporaryFileName

public java.lang.String getTemporaryFileName(java.lang.String exportType)
Access to a temporary file path to store content.

Parameters:
exportType - an export type
Returns:
a temporary file name

getTemporaryFileName

public java.lang.String getTemporaryFileName(java.lang.String exportType,
                                             java.lang.String prefix,
                                             java.lang.String extension)
Access to a temporary file path to store content.

Parameters:
exportType - the export type
prefix - a prefix
extension - an extension
Returns:
a temporary file name

exportAsString

public java.lang.String exportAsString(java.util.Vector<LyFieldInfo> fields,
                                       java.lang.String fieldSep,
                                       java.lang.String valueSep,
                                       java.lang.String exportType)
Export the objects as a single string.

Parameters:
fields - list of fieldInfos that should be saveed to the file.
fieldSep - separator between fields (columns)
valueSep - separator between multiple values
exportType - type of data to export : Possible values are SELECT_EXPORT_TYPE_TEXT (.txt), SELECT_EXPORT_TYPE_RAW (.res), SELECT_EXPORT_TYPE_SPREADSHEET (.csv) or SELECT_EXPORT_TYPE_XML (.xml).
Returns:
a string corresponding to the export

export

public void export(java.lang.String filePath,
                   java.util.Vector<LyFieldInfo> fields,
                   java.lang.String fieldSep,
                   java.lang.String valueSep,
                   java.lang.String exportType)
Save the objects to the file. If the file directory does not exist, this method attemps to create it.

Parameters:
filePath - path of the save file
fields - list of fieldInfos that should be saveed to the file.
fieldSep - separator between fields (columns)
valueSep - separator between multiple values
exportType - type of data to export : Possible values are SELECT_EXPORT_TYPE_TEXT (.txt), SELECT_EXPORT_TYPE_RAW (.res), SELECT_EXPORT_TYPE_SPREADSHEET (.csv) or SELECT_EXPORT_TYPE_XML (.xml).

questionAnswer

public void questionAnswer(boolean result,
                           java.lang.Object clientData)
Answer to a askQuestion request.

Specified by:
questionAnswer in interface LyQuestionAnswerInterface
Parameters:
result - true if the user has clicked on Yes or Ok
clientData - data specified in the askQuestion method
See Also:
LyQuestionAnswerInterface

preview

public void preview(java.util.Vector<LyFieldInfo> fields,
                    java.lang.String fieldSep,
                    java.lang.String valueSep)
Preview the exported data.

Parameters:
fields - list of fieldInfos that should be exported to the file.
fieldSep - separator between fields (columns)
valueSep - separator between multiple values

showExportForm

public void showExportForm()
Shows the export form. Called by the preview controller when closing.


getContent

public LyObjectList getContent()
Get content of the chart.

Overrides:
getContent in class LyAreaController
Returns:
the list of objects being displayed

getClassInfo

public LyClassInfo getClassInfo()
Accessor to the classInfo associated to this form.

Overrides:
getClassInfo in class LyAreaController
Returns:
the reference to the classInfo, never returns null. (mandatory in creation)

isViewResizable

public boolean isViewResizable()
Indicates if the view for this import controller is resizable.

Overrides:
isViewResizable in class LyAreaController
Returns:
true if the view is resizable, false otherwise.

getExportType

public java.lang.String getExportType()
Accessor to the export type selected in the GUI.

Returns:
the type of export from the GUI Possible values are SELECT_EXPORT_TYPE_TEXT (.txt), SELECT_EXPORT_TYPE_RAW (.res) or SELECT_EXPORT_TYPE_SPREADSHEET (.csv).

getExportCharset

public java.lang.String getExportCharset()
Accessor to the export charset.

Returns:
the charset specified in the action. Default is null.

getFile

public java.io.File getFile()
Accessor to the file.

Returns:
current file to save

setFile

public void setFile(java.io.File f)
Accessor to the file.

Parameters:
f - file to save

isSilent

public boolean isSilent()
Checks if this export is in silent mode.

Returns:
the silent mode status

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com