|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectworkspace.FactoryManager
public class FactoryManager
***********************OVERVIEW************************** The FactoryManager manages all block factories in the workspace. It has three main functions: to control and display all factories in one simple UI design, to manage the additions of new drawers, and to add blocks to throse drawers appropriately. The FactoryManager manages two factories: the static factory and dynamic factory. Each factory has a set of drawers. NO TWO DRAWERS WITHIN ANY FACTORY MAY SHARE the same name. ********************FACTORY STRUCTURE*********************** Let's take a look into the stucture of a factory. Factory is a pallete that sits on the far left side of the workspace. It has a bunch of drawers that slides up and down. Each drawer contains a bunch of related blocks that can be dragged out. The FactoryManager has two types of drawers: static and dynamic. To add, remove, rename, drawers of either type, users should invoke the name that specifies a particular drawer. Users may also add blocks to the drawers or retrieve the set of blocks that each drawer holds. *************IMPLEMENTATION DETAIL****************** How the FactoryManager implements this UI is implementation dependant. Right now, it uses the Navigator-Explorer-Canvas deisgn. Clients of the FactoryManager should know nothing about the internal GUIs used to control the interface. Internally, a Canvas (rahter than an instance of Drawer) is created for every "drawer" that the user wishes to add. But this is an implementation detail that the user should not be bothered with. All the user should know is that a "drawer" specified by some String object was created. The handling of the drawers themselves are dealt with internally. In a previous design of the factories, developers had to create instance of Drawers and pass them along to the the factories. In the NEW design, we remove that burden from the developer and allow the developer to access drawers by calling its name only. This may limit extensibility but keeps the system more robust. *********************A WORD ON DRAWER********************** Please note that the word "drawer" as it is used by the FactoryManager refers to the object that holds blocks. A factory holds a bunch of drawers, which in turn holds a bunch of blocks. Please do not mix this definition with the CSwing Drawer class. A CSwing Drawer is a low-level component that is used in a CSwing Exlorer. Here, when the documentation refers to drawers, it is NOT refering to the CSwing Drawer. Rather, when we say "drawer", we are referign to that object that holds blocks. *****************NAMING OF DRAWERS************************* Each factory may have only ONE drawer with a particular name. Two different factories may NOT share a name. If we have a static drawer named "FOO", we may not have another drawer named "FOO" in the dynamic drawers.
Constructor Summary | |
---|---|
FactoryManager(boolean hasStatic,
boolean hasDynamic)
Constucts new Factorymanager |
Method Summary | |
---|---|
void |
addBlock(RenderableBlock block)
Adds the specified block to this widget interally and graphically. |
void |
addBlocks(java.util.Collection<RenderableBlock> blocks)
Adds a collection of blocks to this widget internally and graphically. |
void |
addDynamicBlock(RenderableBlock block,
java.lang.String drawer)
|
void |
addDynamicBlocks(java.util.Collection<RenderableBlock> blocks,
java.lang.String drawer)
|
void |
addDynamicDrawer(java.lang.String name)
Adds a static drawer if no drawer with the specified name already exists. |
void |
addDynamicDrawer(java.lang.String name,
int position)
Adds a duynamic drawer if no drawer with the specified name already exists. |
void |
addStaticBlock(RenderableBlock block,
java.lang.String drawer)
Add blocks to drawer if drawer can be found. |
void |
addStaticBlocks(java.util.Collection<RenderableBlock> blocks,
java.lang.String drawer)
Add blocks to drawer if drawer can be found. |
void |
addStaticDrawer(java.lang.String name,
java.awt.Color color)
Adds a static drawer if no drawer with the specified name already exists. |
void |
addStaticDrawer(java.lang.String name,
int position,
java.awt.Color color)
Adds a static drawer if no drawer with the specified name already exists. |
void |
addSubsetBlocks(java.util.Collection<RenderableBlock> blocks,
java.lang.String drawerName)
Adds the specified RenderableBlocks to the drawer with the specified drawerName. |
void |
addSubsetDrawer(java.lang.String name,
java.awt.Color color)
Adds a new Subset drawer with the specified name and button color. |
void |
addSubsetDrawer(java.lang.String name,
int position,
java.awt.Color color)
Adds a new Subset drawer with the specified name and button color at the specified position. |
void |
blockDragged(RenderableBlock block)
Called by RenderableBlocks as they are dragged over this Widget. |
void |
blockDropped(RenderableBlock block)
Called by RenderableBlocks that get "dropped" onto this Widget |
void |
blockEntered(RenderableBlock block)
Called when a RenderableBlock is being dragged and goes from being outside this Widget to being inside the Widget. |
void |
blockExited(RenderableBlock block)
Called when a RenderableBlock that was being dragged over this Widget goes from being inside this Widget to being outside the Widget. |
void |
componentHidden(java.awt.event.ComponentEvent e)
|
void |
componentMoved(java.awt.event.ComponentEvent e)
|
void |
componentResized(java.awt.event.ComponentEvent e)
|
void |
componentShown(java.awt.event.ComponentEvent e)
|
boolean |
contains(int x,
int y)
Widgets must be able to report whether a given point is inside them |
java.util.Collection<RenderableBlock> |
getBlocks()
Returns the set of blocks that abstract "lives" inside this widget. |
java.util.Collection<RenderableBlock> |
getDynamicBlocks(java.lang.String name)
|
java.util.Collection<java.lang.String> |
getDynamicDrawers()
|
javax.swing.JComponent |
getFactorySwitcher()
|
javax.swing.JComponent |
getJComponent()
Very Java Swing dependent method |
Navigator |
getNavigator()
|
java.util.Collection<SearchableContainer> |
getSearchableContainers()
|
java.util.Collection<RenderableBlock> |
getStaticBlocks(java.lang.String name)
|
java.util.Collection<java.lang.String> |
getStaticDrawers()
|
java.util.Collection<Subset> |
getSubsets()
Returns a collection of the subsets within this |
void |
relayoutBlocks()
Relayout all the drawers |
void |
removeBlock(RenderableBlock block)
Used by RenderableBlocks to tell their originating Widgets that they're moving somewhere else and so should be removed. |
void |
removeDynamicBlock(RenderableBlock block,
java.lang.String drawer)
|
void |
removeDynamicDrawer(java.lang.String name)
|
void |
removeStaticBlock(RenderableBlock block,
java.lang.String drawer)
Removes block from specified drawer. |
void |
removeStaticDrawer(java.lang.String name)
removes drawer with specified name. |
void |
renameDynamicDrawer(java.lang.String oldName,
java.lang.String newName)
|
void |
renameStaticDrawer(java.lang.String oldName,
java.lang.String newName)
Renames drawer from oldName to newName. |
void |
reset()
Resets FactoryManager |
void |
setupSubsets(java.util.Collection<Subset> subsets,
boolean usingSys,
boolean usingSubs)
Sets up the subsets by clearing all subsets and installing the new collection of subsets. |
java.lang.String |
toString()
|
void |
viewDynamicDrawers()
Switch view to the set of dynamic drawers |
void |
viewStaticDrawers()
Swicth view to the set of static drawers |
void |
viewSubsetsDrawers()
|
void |
workspaceEventOccurred(WorkspaceEvent event)
Invoked whenever any of the enumerated events specified within WorkspaceEvent occur. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FactoryManager(boolean hasStatic, boolean hasDynamic)
hasStatic
- hasDynamic
- Method Detail |
---|
public void reset()
public void setupSubsets(java.util.Collection<Subset> subsets, boolean usingSys, boolean usingSubs)
subsets
- - collection of subsetsusingSys
- - true for factory and myblocksusingSubs
- - true for subsetspublic void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
public void relayoutBlocks()
public Navigator getNavigator()
public java.util.Collection<SearchableContainer> getSearchableContainers()
public java.util.Collection<Subset> getSubsets()
public java.util.Collection<java.lang.String> getStaticDrawers()
public java.util.Collection<java.lang.String> getDynamicDrawers()
public void viewStaticDrawers()
public void viewDynamicDrawers()
public void viewSubsetsDrawers()
public void addStaticDrawer(java.lang.String name, java.awt.Color color)
name
- - name os drawer, may not be nullcolor
- public void addStaticDrawer(java.lang.String name, int position, java.awt.Color color)
name
- - name os drawer, may not be nullcolor
- position
- public void addSubsetDrawer(java.lang.String name, java.awt.Color color)
name
- String name of new subset drawer, should not be nullcolor
- Color of drawer buttonpublic void addSubsetDrawer(java.lang.String name, int position, java.awt.Color color)
name
- String name of the new subset drawer, should not be null.position
- index of drawer button position in block drawer setcolor
- button color of drawerpublic void addDynamicDrawer(java.lang.String name)
name
- - name os drawer, may not be nullpublic void addDynamicDrawer(java.lang.String name, int position)
name
- - name os drawer, may not be nullposition
- public void renameStaticDrawer(java.lang.String oldName, java.lang.String newName)
oldName
- newName
- public void renameDynamicDrawer(java.lang.String oldName, java.lang.String newName)
public void removeStaticDrawer(java.lang.String name)
name
- public void removeDynamicDrawer(java.lang.String name)
public java.util.Collection<RenderableBlock> getStaticBlocks(java.lang.String name)
public java.util.Collection<RenderableBlock> getDynamicBlocks(java.lang.String name)
public java.util.Collection<RenderableBlock> getBlocks()
WorkspaceWidget
getBlocks
in interface WorkspaceWidget
public void addStaticBlock(RenderableBlock block, java.lang.String drawer)
block
- drawer
- public void addDynamicBlock(RenderableBlock block, java.lang.String drawer)
public void addStaticBlocks(java.util.Collection<RenderableBlock> blocks, java.lang.String drawer)
blocks
- drawer
- public void addDynamicBlocks(java.util.Collection<RenderableBlock> blocks, java.lang.String drawer)
public void addSubsetBlocks(java.util.Collection<RenderableBlock> blocks, java.lang.String drawerName)
blocks
- Collection of RenderableBlocks to the drawer with name: drawerNamedrawerName
- String name of the drawer to add blocks topublic void removeStaticBlock(RenderableBlock block, java.lang.String drawer)
block
- drawer
- public void removeDynamicBlock(RenderableBlock block, java.lang.String drawer)
public void blockEntered(RenderableBlock block)
WorkspaceWidget
blockEntered
in interface WorkspaceWidget
block
- the RenderableBlock being draggedpublic void blockExited(RenderableBlock block)
WorkspaceWidget
blockExited
in interface WorkspaceWidget
block
- the RenderableBlock being draggedpublic void blockDragged(RenderableBlock block)
WorkspaceWidget
blockDragged
in interface WorkspaceWidget
block
- the RenderableBlock being draggedpublic void removeBlock(RenderableBlock block)
WorkspaceWidget
removeBlock
in interface WorkspaceWidget
block
- the RenderableBlockpublic void addBlock(RenderableBlock block)
WorkspaceWidget
addBlock
in interface WorkspaceWidget
block
- the desired RenderableBlock to add to thispublic void addBlocks(java.util.Collection<RenderableBlock> blocks)
WorkspaceWidget
addBlocks
in interface WorkspaceWidget
blocks
- the Collection of RenderableBlocks to addpublic void blockDropped(RenderableBlock block)
WorkspaceWidget
blockDropped
in interface WorkspaceWidget
block
- the RenderableBlock that is "dropped" onto this Widgetpublic javax.swing.JComponent getJComponent()
WorkspaceWidget
getJComponent
in interface WorkspaceWidget
public javax.swing.JComponent getFactorySwitcher()
public boolean contains(int x, int y)
WorkspaceWidget
contains
in interface WorkspaceWidget
public void workspaceEventOccurred(WorkspaceEvent event)
WorkspaceListener
workspaceEventOccurred
in interface WorkspaceListener
event
- WorkspaceEvent object holding information regarding the triggered
event.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |