tecgraf.javautils.excel.v1.util
Class ExcelAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by tecgraf.javautils.excel.v1.util.ExcelAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public abstract class ExcelAction
extends AbstractAction

Ação que serve para exportar os dados de um componente para o formato XLS.

Author:
mjulia
See Also:
Serialized Form

Nested Class Summary
static class ExcelAction.StringUtils
          Classe utilitária
static class ExcelAction.XLSFilter
          Filtro que aceita arquivos cuja extensão seja xls.
 
Field Summary
 Component owner
          A janela de onde essa ação é chamada
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ExcelAction(Component owner, String title)
          Construtor.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Executa a ação de exportar um componente para o formato XLS.
protected  File createFileForWrite(Component owner, String filePath)
          Cria um arquivo xls para escrita.
protected  void export(PoiExcel excel, File file)
           
protected  String getExportFileName()
          Obtém o nome do arquivo a ser utilizado.
protected  String getFileExistsMessage(File originalFile, File file)
           
protected  String getFileExistsTitle()
           
abstract  ExcelModel[] getModels()
          Retorna os modelos
protected  String getNoTitle()
           
protected  String getYesTitle()
           
protected  void handler(Throwable e)
           
static void main(String[] args)
          Testador
protected  void openInEDT(File file)
           
protected  void runLaterInEDT(Runnable r)
           
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owner

public Component owner
A janela de onde essa ação é chamada

Constructor Detail

ExcelAction

public ExcelAction(Component owner,
                   String title)
Construtor.

Parameters:
owner - a janela de onde essa ação é chamada
title -
Method Detail

getModels

public abstract ExcelModel[] getModels()
Retorna os modelos

Returns:
modelos

actionPerformed

public void actionPerformed(ActionEvent evt)
Executa a ação de exportar um componente para o formato XLS.

Parameters:
evt - o evento ocorrido

handler

protected void handler(Throwable e)
Parameters:
e -

openInEDT

protected void openInEDT(File file)
Parameters:
file -

export

protected void export(PoiExcel excel,
                      File file)
               throws IOException
Parameters:
excel -
file -
Throws:
FileNotFoundException
IOException

createFileForWrite

protected File createFileForWrite(Component owner,
                                  String filePath)
Cria um arquivo xls para escrita. Se o nome do arquivo passado como parâmetro já existir no diretório, pergunta ao usuário se quer criar um outro com o nome pós-fixado com um número que o diferencia do original. Se o usuário confirmar, o arquivo com o novo nome é criado. Senão, o arquivo não é criado.

Parameters:
owner - a janela pai
filePath - o caminho para o arquivo que se deseja criar
Returns:
o arquivo criado que pode ter o nome solicitado ou um nome diferente no caso do solicitado já existir

getExportFileName

protected String getExportFileName()
Obtém o nome do arquivo a ser utilizado.

Returns:
nome do arquivo a ser utilizado.

getFileExistsTitle

protected String getFileExistsTitle()
Returns:
título

getFileExistsMessage

protected String getFileExistsMessage(File originalFile,
                                      File file)
Parameters:
originalFile -
file -
Returns:
menssagem

getYesTitle

protected String getYesTitle()
Returns:
título

getNoTitle

protected String getNoTitle()
Returns:
título

runLaterInEDT

protected void runLaterInEDT(Runnable r)
Parameters:
r -

main

public static void main(String[] args)
Testador

Parameters:
args -


Copyright © 2014 Tecgraf/PUC-Rio. All rights reserved.