JET

edu.utep.cs.jet.gui
Class FileActionFactory

java.lang.Object
  extended by edu.utep.cs.jet.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).

Author:
Yoonsik Cheon

Field Summary
protected  File compilationDirectory
          The directory in which the last compilation was performed.
protected static File currentFile
          The current file being edited.
protected  Mainable et
          The main program.
protected  JFrame frame
          The main frame of this program.
protected  edu.utep.cs.jet.gui.ViewController viewController
          The associated view controller.
 
Fields inherited from interface edu.utep.cs.jet.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, edu.utep.cs.jet.gui.ViewController vc)
          Creates a new instance for the given tool et.
 
Method Summary
 AbstractAction getClose()
          Returns an action for the close menu item.
 AbstractAction getCloseAll(edu.utep.cs.jet.gui.WorkingPane workingPane)
          Returns an action for the closeAll menu item.
 DropTarget getDropTarget()
          Returns a drop target object that accepts dropping of files on the Java editor.
static Mainable getET()
           
 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.
 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()
          Returns the test action.
 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.
 boolean getTestOP()
           
 File locateFile(String filename)
          Given a relative path name, finds the file.
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

compilationDirectory

protected File compilationDirectory
The directory in which the last compilation was performed. It is used to locate the source code files mentioned in the error messages.


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.


viewController

protected edu.utep.cs.jet.gui.ViewController viewController
The associated view controller.

Constructor Detail

FileActionFactory

public FileActionFactory(Mainable et,
                         edu.utep.cs.jet.gui.ViewController vc)
Creates a new instance for the given tool et.

Method Detail

getNew

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


getOpen

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


getSave

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


getSaveAs

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


getPrint

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


getPrinterSetup

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


getClose

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


getCloseAll

public AbstractAction getCloseAll(edu.utep.cs.jet.gui.WorkingPane workingPane)
Returns an action for the closeAll menu item.


getExit

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


getPopOpen

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


getPopTest

public AbstractAction getPopTest()
Returns the test action.


getPopDelete

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


getPopNew

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


getPopRefresh

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


getPopRootDir

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


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.


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.


locateFile

public File locateFile(String filename)
Given a relative path name, finds the file. If the file can't be found, null is returned. The file name is parsed from an error message and supposed to be relative to the directory in which the last compilation was done.


getET

public static Mainable getET()

getTestOP

public boolean getTestOP()

JET

JET is Copyright (C) 2005-2008 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.