com.e1.mxdublin
Class DublinProject

java.lang.Object
  extended by com.e1.mxdublin.DublinProject

public class DublinProject
extends Object

This class encapsulate a DublinProject. Each MaxObject is associated to a single project. In this project, there is


Field Summary
 File projectFile
          The project file pointer.
 
Method Summary
 void addActionListener(ActionListener l)
          Add an action listener to this project when a new file is read or written.
 void associateFrame(JFrame f)
          Add this frame to the registry associated to this project.
 void closeConsole()
           
 void dispose(Trail trail)
          Remove and top trail from the project.
 void disposeAll()
          Stops all trails and release MaxClock objects.
 void execFile(String file)
          Execute code for file.
 void execSnippet(String name)
          Execute python snippet named name
 void execString(String code)
          Execute python code in code
 DublinMaxObject getMaxObject()
           
 JythonBridge getPythonInterpreter()
          Returns the running python interpreter instance.
 int getRunningTrails()
          Returns the number of running trails in the project.
 String getSnippet(String name)
          Returns the python code from the snippet name.
 SortedMap<String,String> getSnippets()
          Returns current project snippets.
 int getStoppedTrails()
          Returns the number of stopped trails in the project.
 Trail getTrail(String name)
          Returns a trail from its name.
 ListModel getTrailListModel()
          Returns the list of active trails.
 Collection<Trail> getTrails()
          Return a copy of registered trails.
 void load(File openFile)
          Open project from file.
 void newProject()
          Creates a new project; this will: cancel all trails, remove all group properties and clear all snippets.
 void register(Trail t)
          Tells dublin that a new Trail needs to be added to the registry.
 void removeActionListener(ActionListener l)
           
 void renameTrail(Trail trail, String value)
           
 void save()
          Save current project using projectFile.
 void save(File saveFile)
          Save project to file.
 void showConsole()
           
 void start()
          Starts all registred trails.
 void stop()
          Stops all trails even if they are not running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

projectFile

public File projectFile
The project file pointer. This will be used if the API save() is trying to save the project. It is initialized with load(File) and save(File).

Method Detail

newProject

public void newProject()
Creates a new project; this will: cancel all trails, remove all group properties and clear all snippets.


save

public void save()
Save current project using projectFile. It is the callee job to check if the projectFile is initialized.


save

public void save(File saveFile)
Save project to file. Once it is saved, projectFile will be initialize with savedFile.

Parameters:
saveFile - the file to use to save the project

load

public void load(File openFile)
Open project from file. Once opened, projectFile will be initialize to openFile

Parameters:
openFile - the file to open

getSnippet

public String getSnippet(String name)
Returns the python code from the snippet name.

Parameters:
name - the name of the snippet
Returns:
the python code

getSnippets

public SortedMap<String,String> getSnippets()
Returns current project snippets.

Returns:
the snippets from the project.

addActionListener

public void addActionListener(ActionListener l)
Add an action listener to this project when a new file is read or written. Two action event will be sended : "saving" and "updated"

Parameters:
l - the action listener to add to monitor project

removeActionListener

public void removeActionListener(ActionListener l)

showConsole

public void showConsole()

closeConsole

public void closeConsole()

associateFrame

public void associateFrame(JFrame f)
Add this frame to the registry associated to this project. If this project get reset, all associated windows will be closed.

Parameters:
f - frame to add to registry.

getPythonInterpreter

public JythonBridge getPythonInterpreter()
Returns the running python interpreter instance.

Returns:
the python interpreter

execFile

public void execFile(String file)
Execute code for file. The URI like form cp:///blabla.py can be used to search a file from classpath. TODO: this method should use a URI not a 'file'...


execString

public void execString(String code)
Execute python code in code

Parameters:
code - the code to execute

execSnippet

public void execSnippet(String name)
Execute python snippet named name

Parameters:
name - the name of the snippet to execute

register

public void register(Trail t)
Tells dublin that a new Trail needs to be added to the registry. If there is also another trail with the same name it will be removed from the registry.

Parameters:
t - the trail to add

disposeAll

public void disposeAll()
Stops all trails and release MaxClock objects.


dispose

public void dispose(Trail trail)
Remove and top trail from the project.


renameTrail

public void renameTrail(Trail trail,
                        String value)

start

public void start()
Starts all registred trails.


stop

public void stop()
Stops all trails even if they are not running. Just in case.


getRunningTrails

public int getRunningTrails()
Returns the number of running trails in the project.

Returns:
number of running trails

getStoppedTrails

public int getStoppedTrails()
Returns the number of stopped trails in the project.

Returns:
number of stopped trails

getTrailListModel

public ListModel getTrailListModel()
Returns the list of active trails.

Returns:
the ListModel, to be used with JList

getTrails

public Collection<Trail> getTrails()
Return a copy of registered trails.

Returns:
registered trails

getTrail

public Trail getTrail(String name)
Returns a trail from its name.

Parameters:
name - trail name
Returns:
the trail if found otherwise null

getMaxObject

public DublinMaxObject getMaxObject()