JET

edu.utep.cs.et.gui
Class FileActionFactory

java.lang.Object
  extended by edu.utep.cs.et.gui.FileActionFactory
All Implemented Interfaces:
Constants
Direct Known Subclasses:
ToolActionFactory

public class FileActionFactory
extends Object
implements Constants

A factory class to create various file manipulation actions. These actions are used to create (file) menu items or tool bar items ( see the class MenuFactory).


Nested Class Summary
private static class FileActionFactory.JavaFileFilter
          A file filter class to filter out non-java files.
private static class FileActionFactory.PrinterSetupThread
          A thread class to set up the page layout for printing.
private static class FileActionFactory.PrintingThread
          A thread class to print document.
 
Field Summary
private static AbstractAction actClose
          The action for the close menu.
private static AbstractAction actExit
          The action for the exit menu.
private static AbstractAction actNew
          The action for the new menu.
private static AbstractAction actOpen
          The action for the open menu.
private static AbstractAction actPopDelete
          The action for the popup delete menu.
private static AbstractAction actPopNew
          The action for the popup new menu.
private static AbstractAction actPopOpen
          The action for the load menu.
private static AbstractAction actPopRefresh
          The action for the popup refresh menu.
private static AbstractAction actPopRootDir
          The action for the popup change root dir menu.
private static AbstractAction actPopTest
          The action for the Popup test menu.
private static AbstractAction actPrint
          The action for the print menu.
private static AbstractAction actPrinterSetup
          The action for the printer setup menu.
private static AbstractAction actSave
          The action for the save menu.
private static AbstractAction actSaveAs
          The action for the save as menu.
private static JFileChooser chooser
          The file chooser to prompt the user to choose a file.
protected static File currentFile
          The current file being edited.
private static JFileChooser dirChooser
          The file chooser to prompt the user to choose a directory.
protected  Mainable et
          The main program.
protected  JFrame frame
          The main frame of this program.
private static PageFormat pageFormat
          The page format for printing.
 
Fields inherited from interface edu.utep.cs.et.gui.Constants
CLASS_EXTENSION, COLOR_EXPLORER, COLOR_OUTPUT, COPYRIGHT, DEBUG, DIVIDER_SIZE, EDIT_MENU_NAME, EXPLORER_DIR, EXPLORER_ROOT, FILE_MENU_NAME, HELP_MENU_NAME, ICON_ABOUT, ICON_ABSTRACT_CLASS, ICON_BROWSER, ICON_CLASS, ICON_CLASS_DISABLED, ICON_DELETE, ICON_ERROR, ICON_FILE, ICON_FOLDER, ICON_GEN_APP, ICON_HOME, ICON_INFORM, ICON_INTERFACE, ICON_JAVA_FILE, ICON_JML_LOGO, ICON_METHOD, ICON_METHOD_GREEN, ICON_METHOD_ORANGE, ICON_METHOD_RED, ICON_MINER, ICON_NEW, ICON_NEWTESTSUITE, ICON_NOTE, ICON_OPEN, ICON_OUTPUT, ICON_PREFERENCES, ICON_QUESTION, ICON_REDO, ICON_SAVE_AS, ICON_TEST_FILE, ICON_UNDO, ICON_UNKOWN, ICON_WARN, JAVA, JAVA_EXTENSION, JAVAC, JUNIT_SWINGGUI_TESTRUNNER, NEWLINE, OPTION_MENU_NAME, TEST_MENU_NAME, TITLE, TOOL_MENU_NAME, VERSION, WEB_PAGE_LOCATION, WEB_PAGE_NAME, WINDOW_HEIGHT, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH, WINDOW_WIDTH
 
Constructor Summary
FileActionFactory(Mainable et)
          Creates a new instance for the given tool et.
 
Method Summary
private  void changeRootDir()
          Change the root directory of the directory browser.
private  void doDrop(String filename)
          Drops the given file on the tool by opening it.
private  void doNew()
          Starts a new document by saving the current buffer if there are unsaved changes.
private  boolean fileSaveAs()
          Saves the contents of the editor buffer to a file by prompting the user for a (new) file name.
 AbstractAction getClose()
          Returns an action for the close menu item.
 DropTarget getDropTarget()
          Returns a drop target object that accepts dropping of files on the Java editor.
 AbstractAction getExit()
          Returns an action for the exit menu item.
protected  ImageIcon getIcon(String name)
          Returns an image icon whose image is read from the file named name.
 AbstractAction getNew()
          Returns an action for the new menu item.
private  File getNewSaveFile()
           
 AbstractAction getOpen()
          Returns an action for the open menu item.
 AbstractAction getPopDelete()
          Returns an action for the popup delete menu item.
 AbstractAction getPopNew()
          Returns an action for the popup new menu item.
 AbstractAction getPopOpen()
          Returns the open action for the popup menu.
 AbstractAction getPopRefresh()
          Returns an action for the popup refresh menu item.
 AbstractAction getPopRootDir()
          Returns an action for the popup change root dir menu item.
 AbstractAction getPopTest()
           
 AbstractAction getPrint()
          Returns an action for the print menu item.
 AbstractAction getPrinterSetup()
          Returns an action for the printer setup menu item.
 AbstractAction getSave()
          Returns an action for the save menu item.
 AbstractAction getSaveAs()
          Returns an action for the save as menu item.
private  File getSaveFile()
          Returns a (new) file to save the contents of the editor buffer.
protected  boolean saveIfModified()
          Saves the contents of the editor buffer only if there are unsaved changes.
protected  void setCurrentFile(File file)
          Sets the given file to be the current file being edited.
static void updatePopupActions(File file)
          Enables or Disables the popup actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actNew

private static AbstractAction actNew
The action for the new menu.


actOpen

private static AbstractAction actOpen
The action for the open menu.


actClose

private static AbstractAction actClose
The action for the close menu.


actSave

private static AbstractAction actSave
The action for the save menu.


actSaveAs

private static AbstractAction actSaveAs
The action for the save as menu.


actPrinterSetup

private static AbstractAction actPrinterSetup
The action for the printer setup menu.


actPrint

private static AbstractAction actPrint
The action for the print menu.


actExit

private static AbstractAction actExit
The action for the exit menu.


actPopOpen

private static AbstractAction actPopOpen
The action for the load menu.


actPopTest

private static AbstractAction actPopTest
The action for the Popup test menu.


actPopDelete

private static AbstractAction actPopDelete
The action for the popup delete menu.


actPopNew

private static AbstractAction actPopNew
The action for the popup new menu.


actPopRootDir

private static AbstractAction actPopRootDir
The action for the popup change root dir menu.


actPopRefresh

private static AbstractAction actPopRefresh
The action for the popup refresh menu.


chooser

private static JFileChooser chooser
The file chooser to prompt the user to choose a file.


dirChooser

private static JFileChooser dirChooser
The file chooser to prompt the user to choose a directory.


pageFormat

private static PageFormat pageFormat
The page format for printing.


et

protected final Mainable et
The main program.


frame

protected final JFrame frame
The main frame of this program.


currentFile

protected static File currentFile
The current file being edited. If null, no file is associated with the current buffer being edited.

Constructor Detail

FileActionFactory

public FileActionFactory(Mainable et)
Creates a new instance for the given tool et.

Method Detail

getNew

public AbstractAction getNew()
Returns an action for the new menu item.

  assignable actNew;
 


getOpen

public AbstractAction getOpen()
Returns an action for the open menu item.

  assignable actOpen;
 


doDrop

private void doDrop(String filename)
Drops the given file on the tool by opening it. If there are unsaved changes, they are saved before opening the file.


getSave

public AbstractAction getSave()
Returns an action for the save menu item.

  assignable actSave;
 


getSaveAs

public AbstractAction getSaveAs()
Returns an action for the save as menu item.

  assignable actSaveAs;
 


getPrint

public AbstractAction getPrint()
Returns an action for the print menu item.

  assignable actPrint;
 


getPrinterSetup

public AbstractAction getPrinterSetup()
Returns an action for the printer setup menu item.

  assignable actPrinterSetup;
 


getClose

public AbstractAction getClose()
Returns an action for the close menu item.

  assignable actClose;
 


getExit

public AbstractAction getExit()
Returns an action for the exit menu item.

  assignable actExit;
 


getPopOpen

public AbstractAction getPopOpen()
Returns the open action for the popup menu.

  assignable actPopOpen;
 


getPopTest

public AbstractAction getPopTest()

getPopDelete

public AbstractAction getPopDelete()
Returns an action for the popup delete menu item.

  assignable actPopDelete;
 


getPopNew

public AbstractAction getPopNew()
Returns an action for the popup new menu item.

  assignable actPopNew;
 


getPopRefresh

public AbstractAction getPopRefresh()
Returns an action for the popup refresh menu item.

  assignable actPopRefresh;
 


getPopRootDir

public AbstractAction getPopRootDir()
Returns an action for the popup change root dir menu item.


changeRootDir

private void changeRootDir()
Change the root directory of the directory browser.


getDropTarget

public DropTarget getDropTarget()
Returns a drop target object that accepts dropping of files on the Java editor.


updatePopupActions

public static void updatePopupActions(File file)
Enables or Disables the popup actions.


getIcon

protected ImageIcon getIcon(String name)
Returns an image icon whose image is read from the file named name. A null is returned if reading the file fails.


setCurrentFile

protected void setCurrentFile(File file)
Sets the given file to be the current file being edited. This method also enable or disable the file save action.


doNew

private void doNew()
Starts a new document by saving the current buffer if there are unsaved changes.

  assignable actSave, currentFile;
 


fileSaveAs

private boolean fileSaveAs()
Saves the contents of the editor buffer to a file by prompting the user for a (new) file name.


saveIfModified

protected boolean saveIfModified()
Saves the contents of the editor buffer only if there are unsaved changes. Return true if there are no such changes or such changes are saved successful.


getSaveFile

private File getSaveFile()
Returns a (new) file to save the contents of the editor buffer. If the current editor buffer is associated with a file, that file is returned. Otherwise, the user is prompted to choose a new file. A null is returned if the user-chosen file can't be written.


getNewSaveFile

private File getNewSaveFile()

JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.