controller
Class WorkspaceController

java.lang.Object
  extended by controller.WorkspaceController

public class WorkspaceController
extends java.lang.Object

The WorkspaceController is the starting point for any program using Open Blocks. It contains a Workspace (the block programming area) as well as the Factories (the palettes of blocks), and is responsible for setting up and laying out the overall window including loading some WorkspaceWidgets like the TrashCan.


Field Summary
protected  SearchBar searchBar
           
protected static Workspace workspace
          The single instance of the Workspace Controller
protected  javax.swing.JPanel workspacePanel
           
 
Constructor Summary
WorkspaceController()
          Constructs a WorkspaceController instance that manages the interaction with the codeblocks.Workspace
 
Method Summary
 java.lang.Iterable<SearchableContainer> getAllSearchableContainers()
          Returns an unmodifiable Iterable of SearchableContainers
 java.lang.String getSaveString()
          Returns the save string for the entire workspace.
 javax.swing.JComponent getSearchBar()
          Returns a SearchBar instance capable of searching for blocks within the BlockCanvas and block drawers
 javax.swing.JComponent getWorkspacePanel()
          Returns the JComponent of the entire workspace.
static void initWithLangDefFilePath(java.lang.String langDefFilePath)
           
 void loadBlockLanguage(org.w3c.dom.Element root)
          Loads all the block genuses, properties, and link rules of a language specified in the pre-defined language def file.
 void loadFreshWorkspace()
          Loads a fresh workspace based on the default specifications in the language definition file.
 void loadProject(java.lang.String projectContents)
          Loads the programming project specified in the projectContents.
 void loadProject(java.lang.String projectContents, java.lang.String langDefContents)
          Loads the programming project specified in the projectContents String, which is associated with the language definition file contained in the specified langDefContents.
 void loadProjectFromPath(java.lang.String path)
          Loads the programming project from the specified file path.
static void main(java.lang.String[] args)
           
 void resetLanguage()
          Resets the current language within the active Workspace.
 void resetWorkspace()
          Resets the entire workspace.
 void setLangDefFile(java.io.File langDefFile)
          Sets the Lang Def File to the specified File langDefFile.
 void setLangDefFilePath(java.lang.String filePath)
          Sets the file path for the language definition file, if the language definition file is located in
 void setLangDefFileString(java.lang.String langDefContents)
          Sets the contents of the Lang Def File to the specified String langDefContents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

workspace

protected static Workspace workspace
The single instance of the Workspace Controller


workspacePanel

protected javax.swing.JPanel workspacePanel

searchBar

protected SearchBar searchBar
Constructor Detail

WorkspaceController

public WorkspaceController()
Constructs a WorkspaceController instance that manages the interaction with the codeblocks.Workspace

Method Detail

setLangDefFilePath

public void setLangDefFilePath(java.lang.String filePath)
Sets the file path for the language definition file, if the language definition file is located in


setLangDefFileString

public void setLangDefFileString(java.lang.String langDefContents)
Sets the contents of the Lang Def File to the specified String langDefContents

Parameters:
langDefContents - String contains the specification of a language definition file

setLangDefFile

public void setLangDefFile(java.io.File langDefFile)
Sets the Lang Def File to the specified File langDefFile.

Parameters:
langDefFile - File contains the specification of the a language definition file.

loadBlockLanguage

public void loadBlockLanguage(org.w3c.dom.Element root)
Loads all the block genuses, properties, and link rules of a language specified in the pre-defined language def file.

Parameters:
root - Loads the language specified in the Element root

resetLanguage

public void resetLanguage()
Resets the current language within the active Workspace.


getSaveString

public java.lang.String getSaveString()
Returns the save string for the entire workspace. This includes the block workspace, any custom factories, canvas view state and position, pages

Returns:
the save string for the entire workspace.

loadFreshWorkspace

public void loadFreshWorkspace()
Loads a fresh workspace based on the default specifications in the language definition file. The block canvas will have no live blocks.


loadProjectFromPath

public void loadProjectFromPath(java.lang.String path)
Loads the programming project from the specified file path. This method assumes that a Language Definition File has already been specified for this programming project.

Parameters:
path - String file path of the programming project to load

loadProject

public void loadProject(java.lang.String projectContents)
Loads the programming project specified in the projectContents. This method assumes that a Language Definition File has already been specified for this programming project.

Parameters:
projectContents -

loadProject

public void loadProject(java.lang.String projectContents,
                        java.lang.String langDefContents)
Loads the programming project specified in the projectContents String, which is associated with the language definition file contained in the specified langDefContents. All the blocks contained in projectContents must have an associted block genus defined in langDefContents. If the langDefContents have any workspace settings such as pages or drawers and projectContents has workspace settings as well, the workspace settings within the projectContents will override the workspace settings in langDefContents. NOTE: The language definition contained in langDefContents does not replace the default language definition file set by: setLangDefFilePath() or setLangDefFile().

Parameters:
projectContents -
langDefContents - String XML that defines the language of projectContents

resetWorkspace

public void resetWorkspace()
Resets the entire workspace. This includes all blocks, pages, drawers, and trashed blocks. Also resets the undo/redo stack. The language (i.e. genuses and shapes) is not reset.


getWorkspacePanel

public javax.swing.JComponent getWorkspacePanel()
Returns the JComponent of the entire workspace.

Returns:
the JComponent of the entire workspace.

getSearchBar

public javax.swing.JComponent getSearchBar()
Returns a SearchBar instance capable of searching for blocks within the BlockCanvas and block drawers


getAllSearchableContainers

public java.lang.Iterable<SearchableContainer> getAllSearchableContainers()
Returns an unmodifiable Iterable of SearchableContainers

Returns:
an unmodifiable Iterable of SearchableContainers

main

public static void main(java.lang.String[] args)

initWithLangDefFilePath

public static void initWithLangDefFilePath(java.lang.String langDefFilePath)