edu.washington.biostr.sig.brainj3d.core.client
Class ClientManager

java.lang.Object
  extended by java.util.Observable
      extended by edu.washington.biostr.sig.brainj3d.core.client.ClientManager
All Implemented Interfaces:
Runnable

public class ClientManager
extends Observable
implements Runnable

Observers listener to this should watch for: FRONT (when the front object changes), LAYOUT (when the layout changes).
While quiting should be done by ClientManager2's quit methods, the ClientManager2

Author:
eider

Field Summary
static String FRONT
          This message is sent to observers when the front view changes.
static String LAYOUT
          This message is sent to observers when the layout changes
static String LIBRARY
          This message is sent when the library changes.
 
Constructor Summary
protected ClientManager(Session session, ExecutorService main)
          Create a new client manager with the given session.
 
Method Summary
static void addRecentLibrary(URI filename)
          Add a loaded library to the recent library list.
 FileType canSave(FileType type)
          Check if a type can be saved.
 boolean close(boolean force)
          Close this ClientManager if possible and return true.
 boolean close(long id)
          Try and close the view specified by id.
 void execute(Runnable r)
          Execute the given runnable in the preferred client thread.
static void forceQuit()
          Forcefully quit the program.
static Set<ClientManager> getAllClientManagers()
           
static LayoutManager getAvailableLayout()
          If any layouts exist return one that corresponds to some window.
 RemoteFileSource getFileSource()
           
 long getFront()
          Get the frontmost component's id.
 LayoutManager getLayout()
          Get the layout manager.
 DataVault getLibrary()
          Return the current library.
 TreeModel getLibraryTreeModel()
          Get the tree model for displaying the library in a tree form.
static ClientManager getManager(Session session, ExecutorService main)
          Create a new ClientManager for the specified session.
 DataVault getMasterLibrary()
          Get the master library.
 ExecutorService getPool()
          Get this client's threadpool
 FileGroup[] getRecent(FileType type)
           
 Session getSession()
          Get the session.
 TreeTemplate getTemplate()
          Get a template node that uses mainTag for its main tag.
 DataVaultTreeBuilder getTreeOrdering()
           
static String getUrlBase()
          The urlBase adds the start to urls to point them in the right direction.
 ViewCapsule getViewCapsule(Long id)
          Get the specified view capsule
 void handleError(Throwable t)
           
 boolean hasEditPermission()
          Check to see if this user has permission to edit things
 void load(FileGroup... g)
           
 void load(String[] str)
          Load the given string.
static boolean quit(boolean exit)
          Quit the whole program.
 void registerSyncObject(Object o)
           
 void run()
          Start this ClientManager.
 void setConnectSplashScreen(ConnectSplashscreen css)
           
 void setCurrentLibrary(DataVault vault)
          Set the current library to vault or default to the master library if vault is null.
 void setFocus(Object focusKey)
           
 void setFront(Long id, int index)
          Set the front component.
 void setLayoutManager(LayoutManager layout)
          Set a new layout manager.
protected  void setupMainView()
          Setup the main window (including libray, timer, menus and other things).
protected static void setupRenderers()
           
static void setUrlBase(String urlBase_)
          The urlBase adds the start to urls to point them in the right direction.
 boolean shouldSave(FileGroup file)
          Check if we should save a file.
 void show(ViewCapsule view)
           
static void showAbout()
           
static void showPrefs()
           
 boolean showSaveDialogAndSave(Set toSave, boolean cancelable)
          Show the save dialog and save any that were selected.
 void showStartup()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT

public static final String LAYOUT
This message is sent to observers when the layout changes

See Also:
Constant Field Values

FRONT

public static final String FRONT
This message is sent to observers when the front view changes.

See Also:
Constant Field Values

LIBRARY

public static final String LIBRARY
This message is sent when the library changes.

See Also:
Constant Field Values
Constructor Detail

ClientManager

protected ClientManager(Session session,
                        ExecutorService main)
                 throws InstantiationException,
                        ClassNotFoundException,
                        IllegalAccessException,
                        RemoteException
Create a new client manager with the given session.

Throws:
InstantiationException
ClassNotFoundException
IllegalAccessException
RemoteException
Method Detail

getPool

public ExecutorService getPool()
Get this client's threadpool

Returns:

getManager

public static ClientManager getManager(Session session,
                                       ExecutorService main)
Create a new ClientManager for the specified session. With the specified layout. This is used when starting the program and it is used to load a new library (Each client manager only supports a single library). Returns null if we are unable to instantiate the session.

Parameters:
session -
main - The threaddispatcher or null if we should create one
Returns:

load

public void load(String[] str)
Load the given string. If this is the first string and it specifies a library, it is loaded. Otherwise if no library exists, a new one from the default template is created.

Parameters:
str -

close

public boolean close(long id)
Try and close the view specified by id. If we can close the view, return true. Otherwise return false.

Parameters:
id -
Returns:
Throws:
NullPointerException - if id doesn't exist or id is null

showStartup

public void showStartup()

setLayoutManager

public void setLayoutManager(LayoutManager layout)
Set a new layout manager.

Parameters:
layout -

setupRenderers

protected static void setupRenderers()

setupMainView

protected void setupMainView()
                      throws RemoteException
Setup the main window (including libray, timer, menus and other things).

Throws:
RemoteException

setConnectSplashScreen

public void setConnectSplashScreen(ConnectSplashscreen css)

getTreeOrdering

public DataVaultTreeBuilder getTreeOrdering()

show

public void show(ViewCapsule view)

getFront

public long getFront()
Get the frontmost component's id.

Returns:

setFront

public void setFront(Long id,
                     int index)
Set the front component. An id of 0 signifies that the library is in front.

Parameters:
id -

getLayout

public LayoutManager getLayout()
Get the layout manager. The layout manager may change, so it is not advisable to keep a local reference. However, if you must maintain a local reference, please register an observer and watch for LAYOUT

Returns:

getViewCapsule

public ViewCapsule getViewCapsule(Long id)
Get the specified view capsule

Parameters:
id -
Returns:

getSession

public Session getSession()
Get the session. To help this play nicely with remote garbage collection, PLEASE don't hold a local reference to the session.

Returns:

handleError

public void handleError(Throwable t)

execute

public void execute(Runnable r)
Execute the given runnable in the preferred client thread.

Parameters:
r -

showSaveDialogAndSave

public boolean showSaveDialogAndSave(Set toSave,
                                     boolean cancelable)
Show the save dialog and save any that were selected.

Parameters:
toSave -
cancelable -
Returns:
true if we can save.

load

public void load(FileGroup... g)

close

public boolean close(boolean force)
Close this ClientManager if possible and return true. Return false if it was not closed.

Parameters:
force - Force this to close and do not display any popups.

quit

public static boolean quit(boolean exit)
Quit the whole program. Call exit if exit is true. Return whether or not the program is ready to quit (or quit if it is ready and exit is true.


forceQuit

public static void forceQuit()
Forcefully quit the program. This method never returns normally. It always does clean up and calls System.exit(non-zero). This is used to terminate the program abnormally and still allow cleanup.


getAllClientManagers

public static Set<ClientManager> getAllClientManagers()

run

public void run()
Start this ClientManager. This is a run method so it can be started easily on the Swing thread

Specified by:
run in interface Runnable

getFileSource

public RemoteFileSource getFileSource()
Returns:
Returns the fileSource.

getUrlBase

public static String getUrlBase()
The urlBase adds the start to urls to point them in the right direction.

Returns:
Returns the urlBase.

setUrlBase

public static void setUrlBase(String urlBase_)
The urlBase adds the start to urls to point them in the right direction.

Parameters:
urlBase - The urlBase to set.

getRecent

public FileGroup[] getRecent(FileType type)

setFocus

public void setFocus(Object focusKey)

showPrefs

public static void showPrefs()

getAvailableLayout

public static LayoutManager getAvailableLayout()
If any layouts exist return one that corresponds to some window.

Returns:

showAbout

public static void showAbout()

getLibrary

public DataVault getLibrary()
Return the current library. The current library is the library with all of the required filters in place.

Returns:

setCurrentLibrary

public void setCurrentLibrary(DataVault vault)
Set the current library to vault or default to the master library if vault is null.

Parameters:
vault -

getMasterLibrary

public DataVault getMasterLibrary()
Get the master library. The master library is unfiltered.

Returns:

getLibraryTreeModel

public TreeModel getLibraryTreeModel()
Get the tree model for displaying the library in a tree form.

Returns:

addRecentLibrary

public static void addRecentLibrary(URI filename)
Add a loaded library to the recent library list.

Parameters:
filename -

shouldSave

public boolean shouldSave(FileGroup file)
Check if we should save a file. A file should be saved if work will be lost when MindSeer shuts down.

Parameters:
file -
Returns:

canSave

public FileType canSave(FileType type)
Check if a type can be saved. A file can be saved if there is an Encoder for its data type and the user has permission to edit things.

Parameters:
type - The type that we want to save as something else.
Returns:
The type that the data will save as or null if it can't be saved.

hasEditPermission

public boolean hasEditPermission()
Check to see if this user has permission to edit things

Returns:

getTemplate

public TreeTemplate getTemplate()
Get a template node that uses mainTag for its main tag.

Parameters:
mainTag -
Returns:

registerSyncObject

public void registerSyncObject(Object o)


Copyright © 2006 University of Washington. All Rights Reserved.