Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.gems.client.browser
Class BrowserTreeModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by org.openquark.gems.client.browser.BrowserTreeModel
All Implemented Interfaces:
Serializable, TreeModel

public class BrowserTreeModel
extends DefaultTreeModel

The model for the browser tree displayed in the outline control. This model contains the abstract tree model and has various methods to construct the displayed tree.

Author:
Luke Evans
See Also:
Serialized Form

Nested Class Summary
static class BrowserTreeModel.DefaultCategoryNodeProvider
          The default category node provider just returns an empty default mutable tree node.
 
Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
BrowserTreeModel()
          Default constructor for BrowserTreeModel.
 
Method Summary
 void arrangeAsDefaultTreeStructure(ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
          Reverts the browser tree model to the "original" structure.
 void categorizeByArity(BrowserTreeNode selectedNode)
          Starting from the currently selected node, we categorize the currently selected node's children according to the child's arity.
 void categorizeByGemType(BrowserTreeNode selectedNode)
          Starting from the currently selected node, we categorize the currently selected node's children according to the child's gem type (type signature).
 void categorizeByInput(BrowserTreeNode selectedNode)
          Starting from the currently selected node, we categorize the currently selected node's children according to the child's input type.
 void categorizeByModule(BrowserTreeNode selectedNode, ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
          Starting from the currently selected node, we categorize the currently selected node's children according to the child's module.
 void categorizeByOutput(BrowserTreeNode selectedNode)
          Starting from the currently selected node, we categorize the currently selected node's children according to the child's output type.
 void clearDrawers()
          Clear all gem drawers from the workspace.
 boolean doesNamespaceContainVisibleModules(ModuleName namespaceName)
          Return whether a given namespace contains modules visible from the perspective from which the tree was last populated.
 void doSearch(String searchString)
          Performs a sub-string search on all node names and type expressions in the model and inserts nodes for matching gems into the search results node.
 FeatureVisibilityPolicy getFeatureVisibilityPolicy()
          Returns the visibility policy used for this browser tree model.
 BrowserTreeNode getSearchResultsNode()
          Returns the tree node that represents the "Search Results" node.
 String getSearchString()
           
 boolean getShowAllModules()
          Determines whether modules not visible from the current perspective should be shown in the tree view.
 boolean getShowPublicGemsOnly()
          Determines whether only public gems should be displayed.
 GemTreeNode getTreeNode(GemEntity newGemEntity)
          Get a GemTreeNode corresponding to a given entity.
 BrowserTreeNode getWorkspaceNode()
          Returns the tree node that represents the "Workspace" node.
 boolean isVisibleGem(GemEntity gemEntity)
          Return whether a given gem is visible from the perspective from which the tree was last populated.
 boolean isVisibleModule(ModuleName moduleName)
          Return whether a given module is visible from the perspective from which the tree was last populated.
 void populate(Perspective perspective, boolean showAllModules, ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
          Populate the model with entities.
 void reload()
          Reloads the model from the perspective it was originally populated from and uses the same parameters as when originally populated.
 void setFeatureVisibilityPolicy(FeatureVisibilityPolicy predicate)
          Sets the visibility policy used for this browser tree model.
 void setPerspectiveAndReload(Perspective perspective)
          Refreshes with a new perspective.
 void setShowAllModules(boolean showAllModules)
          Determines whether modules not visible from the current perspective should be shown in the tree view.
 void setShowPublicGemsOnly(boolean showPublicGemsOnly)
          Determines whether only public gems should be displayed.
 void setWorkspaceNodeName(String name)
          Sets the name of the Workspace node in the tree to include the name of the current workspace in square brackets.
 void sortByForm(BrowserTreeNode treeNode)
          Starting from the currently selected node, we sort the currently selected node's children according to its form (Data Constructor, Supercombinator, Class Method, ...)
 void sortByUnqualifiedName(BrowserTreeNode selectedNode)
          Starting from the currently selected node, we sort the currently selected node's children according to the alphabet: A, a, B, b, etc...
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserTreeModel

public BrowserTreeModel()
Default constructor for BrowserTreeModel. Automatically constructs a root node in the abstract tree and display all modules/gems found in the workspace.

Method Detail

getFeatureVisibilityPolicy

public FeatureVisibilityPolicy getFeatureVisibilityPolicy()
Returns the visibility policy used for this browser tree model. The return value can never be null.

Returns:
FeatureVisibilityPolicy

setFeatureVisibilityPolicy

public void setFeatureVisibilityPolicy(FeatureVisibilityPolicy predicate)
Sets the visibility policy used for this browser tree model. A visibility policy is a predicate function that determines in a module or a gem is visible in the browser tree. If null is used as an argument, then the default visibility predicate is used.

Parameters:
predicate -

isVisibleModule

public boolean isVisibleModule(ModuleName moduleName)
Return whether a given module is visible from the perspective from which the tree was last populated.

Parameters:
moduleName -
Returns:
whether the module is visible from the perspective from which the tree was last populated.

doesNamespaceContainVisibleModules

public boolean doesNamespaceContainVisibleModules(ModuleName namespaceName)
Return whether a given namespace contains modules visible from the perspective from which the tree was last populated.

Parameters:
namespaceName -
Returns:
whether the namespace contains modules visible from the perspective from which the tree was last populated.

isVisibleGem

public boolean isVisibleGem(GemEntity gemEntity)
Return whether a given gem is visible from the perspective from which the tree was last populated.

Parameters:
gemEntity -
Returns:
whether the gem is visible from the perspective from which the tree was last populated.

getTreeNode

public GemTreeNode getTreeNode(GemEntity newGemEntity)
Get a GemTreeNode corresponding to a given entity. This is usually, but NOT ALWAYS, the only node that corresponds to the entity. Some entities will have multiple associated tree nodes; this function returns one chosen arbitrarily.

Parameters:
newGemEntity - the entity to look up
Returns:
GemTreeNode the corresponding node.

categorizeByArity

public void categorizeByArity(BrowserTreeNode selectedNode)
Starting from the currently selected node, we categorize the currently selected node's children according to the child's arity. Note: Categorize means that the children will be put into different folders based on its arity.

Parameters:
selectedNode - The node below which all entities will be categorized.

categorizeByGemType

public void categorizeByGemType(BrowserTreeNode selectedNode)
Starting from the currently selected node, we categorize the currently selected node's children according to the child's gem type (type signature). Note: Categorize means that the children will be put into different folders based on their type.

Parameters:
selectedNode - The node below which all entities will be categorized.

categorizeByOutput

public void categorizeByOutput(BrowserTreeNode selectedNode)
Starting from the currently selected node, we categorize the currently selected node's children according to the child's output type. Note: Categorize means that the children will be put into different folders based on its arity.

Parameters:
selectedNode - The node below which all entities will be categorized.

categorizeByInput

public void categorizeByInput(BrowserTreeNode selectedNode)
Starting from the currently selected node, we categorize the currently selected node's children according to the child's input type. Note: Categorize means that the children will be put into different folders based on their input type.

Parameters:
selectedNode - The node below which all entities will be categorized.

categorizeByModule

public void categorizeByModule(BrowserTreeNode selectedNode,
                               ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
Starting from the currently selected node, we categorize the currently selected node's children according to the child's module.

Parameters:
selectedNode - The node below which all entities will be categorized.
moduleTreeDisplayMode - the display mode for the module tree.

sortByUnqualifiedName

public void sortByUnqualifiedName(BrowserTreeNode selectedNode)
Starting from the currently selected node, we sort the currently selected node's children according to the alphabet: A, a, B, b, etc... Side Note: This method assumes that the gems will have a name of length greater than 0.

Parameters:
selectedNode - The node below which all entities will be sorted.

sortByForm

public void sortByForm(BrowserTreeNode treeNode)
Starting from the currently selected node, we sort the currently selected node's children according to its form (Data Constructor, Supercombinator, Class Method, ...)

Parameters:
treeNode - the node below which all entities will be sorted.

setShowAllModules

public void setShowAllModules(boolean showAllModules)
Determines whether modules not visible from the current perspective should be shown in the tree view. If you change this property you have to reload the module.

Parameters:
showAllModules - if true all modules will be shown, if false only visible modules

getShowAllModules

public boolean getShowAllModules()
Determines whether modules not visible from the current perspective should be shown in the tree view. This value may not reflect what is currently shown in the view since the model needs to be reloaded if the property is changed.

Returns:
boolean true if all modules should be shown, false if only visible modules should be shown

setShowPublicGemsOnly

public void setShowPublicGemsOnly(boolean showPublicGemsOnly)
Determines whether only public gems should be displayed. The value may not reflect what is currently shown in the view, since the model needs to be reloaded if the property is changed.

Parameters:
showPublicGemsOnly - true if only public gems should be shown, false if all gems (public, private, protected)should be shown.

getShowPublicGemsOnly

public boolean getShowPublicGemsOnly()
Determines whether only public gems should be displayed. The value may not reflect what is currently shown in the view, since the model needs to be reloaded if the property is changed.

Returns:
boolean true is only public gems should be shown, false if all gems (public, private, protected)should be shown.

arrangeAsDefaultTreeStructure

public void arrangeAsDefaultTreeStructure(ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
Reverts the browser tree model to the "original" structure. Drawers are organized in import-dependent order - the order depends on the order of imports into the current drawer (based on the perspective at the time the model was populated). Entities are organized in alphabetical order within drawers.

Parameters:
moduleTreeDisplayMode - the display mode for the module tree.

getSearchResultsNode

public BrowserTreeNode getSearchResultsNode()
Returns the tree node that represents the "Search Results" node.

Returns:
the search results tree node

getWorkspaceNode

public BrowserTreeNode getWorkspaceNode()
Returns the tree node that represents the "Workspace" node.

Returns:
the workspace node

setWorkspaceNodeName

public void setWorkspaceNodeName(String name)
Sets the name of the Workspace node in the tree to include the name of the current workspace in square brackets.

Parameters:
name - the name to have in square brackets

doSearch

public void doSearch(String searchString)
Performs a sub-string search on all node names and type expressions in the model and inserts nodes for matching gems into the search results node. The search is case insensitive.

Parameters:
searchString - the string to search for

getSearchString

public String getSearchString()

reload

public void reload()
Reloads the model from the perspective it was originally populated from and uses the same parameters as when originally populated. Tree structure state is not remembered by the model. Use GemBrowser.refresh() to reload the model and maintain the tree structure.

Overrides:
reload in class DefaultTreeModel
See Also:
populate(org.openquark.cal.services.Perspective, boolean, org.openquark.gems.client.ModuleNameDisplayUtilities.TreeViewDisplayMode), GemBrowser.refresh()

populate

public void populate(Perspective perspective,
                     boolean showAllModules,
                     ModuleNameDisplayUtilities.TreeViewDisplayMode moduleTreeDisplayMode)
Populate the model with entities. Note: any modules which already exist both in the tree and in the program will be replaced by the program definition.

Parameters:
perspective - the perspective from which entities are gathered.
showAllModules - whether modules not visible from the given perspective should also be visible.
moduleTreeDisplayMode - the display mode for the module tree.

clearDrawers

public void clearDrawers()
Clear all gem drawers from the workspace.


setPerspectiveAndReload

public void setPerspectiveAndReload(Perspective perspective)
Refreshes with a new perspective.

Parameters:
perspective - the new perspective

Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

Copyright © 2007 Business Objects. All rights reserved.