edu.cs.ai.kreator.control
Class ProjectController

java.lang.Object
  extended by edu.cs.ai.kreator.control.ProjectController
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class ProjectController
extends java.lang.Object
implements java.awt.event.ActionListener

This controller manages projects. Handles opening and closing of projects. Manages the current project: Adding or removing files, command history, ...

Author:
Niklas Wulf, Adam Chachaj

Field Summary
static java.lang.String CMD_ADDFILES
           
static java.lang.String CMD_CLOSEPROJECT
           
static java.lang.String CMD_NEWPROJECT
           
static java.lang.String CMD_OPENGETTINGSTARTED
           
static java.lang.String CMD_OPENPROJECT
           
static java.lang.String GETTING_STARTED_PROJECT
           
static org.apache.log4j.Logger LOG
           
 
Constructor Summary
ProjectController()
          Initializes the ProjectController: Sets the working directory to the user's home and the current project to null.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addDataFile(DataFile file)
          Adds a DataFile to the current project.
 void addDataFiles()
          Asks the user for a list files, which will then be added to the current project.
 boolean canAddFileToProject(DataFile file)
          Returns false in the following situations: - there is no current project - the file is already in the project Then returns true if the file is in the project's directory
 boolean closeProject()
          Closes the current project.
 Project getCurrentProject()
           
 Project getProject(java.io.File file)
          Creates a Project from a File.
 java.io.File getProjectPath()
           
 java.util.List<java.lang.String> getQueryHistory()
           
 void init()
           
 void openGettingStartedProject()
          Opens the getting started project.
 void openProject()
          Shows the user a "Open project..."
 void openProject(java.io.File file)
          Provided for convenience.
 void openProject(Project project)
          Opens a Project in the GUI.
 boolean projectContains(DataFile file)
           
 void removeDataFile(DataFile file)
          Removes a DataFile from the current project.
 void removeDataFileFromTree()
          Removes the currently selected file in the project container from the current project.
 void setQueryHistory(java.util.List<java.lang.String> history)
          Sets the query history.
 boolean shutDown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG

CMD_OPENPROJECT

public static final java.lang.String CMD_OPENPROJECT
See Also:
Constant Field Values

CMD_CLOSEPROJECT

public static final java.lang.String CMD_CLOSEPROJECT
See Also:
Constant Field Values

CMD_ADDFILES

public static final java.lang.String CMD_ADDFILES
See Also:
Constant Field Values

CMD_NEWPROJECT

public static final java.lang.String CMD_NEWPROJECT
See Also:
Constant Field Values

CMD_OPENGETTINGSTARTED

public static final java.lang.String CMD_OPENGETTINGSTARTED
See Also:
Constant Field Values

GETTING_STARTED_PROJECT

public static final java.lang.String GETTING_STARTED_PROJECT
See Also:
Constant Field Values
Constructor Detail

ProjectController

public ProjectController()
Initializes the ProjectController: Sets the working directory to the user's home and the current project to null.

Method Detail

init

public void init()

shutDown

public boolean shutDown()

getCurrentProject

public Project getCurrentProject()

getProject

public Project getProject(java.io.File file)
                   throws ProjectParsingException
Creates a Project from a File.

Parameters:
file -
Returns:
a Project
Throws:
ProjectParsingException

openProject

public void openProject(Project project)
Opens a Project in the GUI. Handles saving of the working directory, last project and command history.

Parameters:
project -

openProject

public void openProject(java.io.File file)
Provided for convenience.
Creates a new project and opens it.
Checks if another project is open and asks the user whether he wants to close it. See getProject(File) and openProject(Project).

Parameters:
file -

openProject

public void openProject()
Shows the user a "Open project..."-Dialog. Opens the project.


openGettingStartedProject

public void openGettingStartedProject()
Opens the getting started project.


closeProject

public boolean closeProject()
Closes the current project.
Closes all currently opened files with respect to their stained status, saves the command history and sets the last project to "". Does not confirm this action.

See Also:
closeProjectConfirmed()

addDataFile

public void addDataFile(DataFile file)
Adds a DataFile to the current project.
Checks if the file may be added to the project. See canAddFileToProject(DataFile) for details.

Parameters:
file -

addDataFiles

public void addDataFiles()
Asks the user for a list files, which will then be added to the current project.


removeDataFile

public void removeDataFile(DataFile file)
Removes a DataFile from the current project. Does not close its tab nor deletes it from the file-system.

Parameters:
file -

removeDataFileFromTree

public void removeDataFileFromTree()
Removes the currently selected file in the project container from the current project.


projectContains

public boolean projectContains(DataFile file)
Parameters:
file -
Returns:
true if the current project contains the DataFile, false if there is no current project

canAddFileToProject

public boolean canAddFileToProject(DataFile file)
Returns false in the following situations: - there is no current project - the file is already in the project Then returns true if the file is in the project's directory

Parameters:
file -

getQueryHistory

public java.util.List<java.lang.String> getQueryHistory()
Returns:
the query history

setQueryHistory

public void setQueryHistory(java.util.List<java.lang.String> history)
                     throws java.io.IOException
Sets the query history.

Parameters:
the - query history
Throws:
java.io.IOException

getProjectPath

public java.io.File getProjectPath()
Returns:
path of the current project file or null if no project is open

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener