com.tensegrity.skeleton.commands
Class FindElementsCommand

java.lang.Object
  extended bycom.tensegrity.generic.command.BaseCommand
      extended bycom.tensegrity.skeleton.commands.CommonBaseCommand
          extended bycom.tensegrity.skeleton.commands.DocumentCommand
              extended bycom.tensegrity.skeleton.commands.GraphDocumentCommand
                  extended bycom.tensegrity.skeleton.commands.FindElementsCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
SwtFindElementsCommand

public class FindElementsCommand
extends GraphDocumentCommand

This Command class looks for occurrences of strings in text attributes of graph elements and selects all matching items.

Version:
$Id: FindElementsCommand.java,v 1.20 2006/01/05 12:33:31 BurkhardWick Exp $
Author:
BurkhardWick

Constructor Summary
FindElementsCommand(ApplicationFrame applicationFrame, java.lang.String command)
          Constructor.
 
Method Summary
protected  java.util.Collection gatherElements()
          Looks through all elements in the VisualGraphView (recursively) and calls matchesFindPattern() for each of them.
protected  java.util.Collection gatherElements(VisualGraphObjectContainer vgv)
          Looks through all elements in the VisualGraphObjectContainer (recursively) and calls matchesFindPattern() for each of them.
protected  void getSearchCriteria()
          Creates the search criteria for this search.
protected  java.lang.String getSearchText()
           Returns the search text.
 boolean isEnabled()
          Overridden to restrict the availability of this command to the case that there are no elements in the graph.
protected  boolean matchesSearchCriteria(VisualGraphObject vgo)
          Checks whether the given VisualGraphObject matches the search criteria.
 void perform(java.lang.Object args)
          Opens a dialog for the user to enter some text and then selects all elements in the current graph whose attribute values contain this text.
protected  void setSearchText(java.lang.String searchText)
           Stores the text which is going to be search for.
protected  void showResults(java.util.Collection elements)
          Shows the results of the search, usually selects the items.
 
Methods inherited from class com.tensegrity.skeleton.commands.GraphDocumentCommand
getGraphDocument, getVisualGraphView
 
Methods inherited from class com.tensegrity.skeleton.commands.DocumentCommand
getDocument, getGraphApplication, newGraphDocumentFromFactory
 
Methods inherited from class com.tensegrity.skeleton.commands.CommonBaseCommand
getApplicationFrame, getTitle
 
Methods inherited from class com.tensegrity.generic.command.BaseCommand
getDescription, getId, getPerformDescription, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindElementsCommand

public FindElementsCommand(ApplicationFrame applicationFrame,
                           java.lang.String command)
Constructor.

Parameters:
applicationFrame - The application frame
command - The id used to register this command in the command registry
Method Detail

perform

public final void perform(java.lang.Object args)
Opens a dialog for the user to enter some text and then selects all elements in the current graph whose attribute values contain this text. Uses functions from the VisualGraphViewUtil.

Specified by:
perform in interface Command
Overrides:
perform in class CommonBaseCommand
Parameters:
args - Ignored
See Also:
VisualGraphViewUtil.findElementsWithAttributeValue(VisualGraphObjectContainer, String)

showResults

protected void showResults(java.util.Collection elements)
Shows the results of the search, usually selects the items.

Parameters:
elements - The matching items that were gathered

getSearchCriteria

protected void getSearchCriteria()
Creates the search criteria for this search. Is called in the perform() method and usually asks the user to enter some information.


isEnabled

public boolean isEnabled()
Overridden to restrict the availability of this command to the case that there are no elements in the graph.

Specified by:
isEnabled in interface Command
Overrides:
isEnabled in class GraphDocumentCommand
Returns:
True, if the command is currently available

matchesSearchCriteria

protected boolean matchesSearchCriteria(VisualGraphObject vgo)
Checks whether the given VisualGraphObject matches the search criteria.

Parameters:
vgo - The VisualGraphObject to check
Returns:
true, if the object matches the search criteria

gatherElements

protected final java.util.Collection gatherElements()
Looks through all elements in the VisualGraphView (recursively) and calls matchesFindPattern() for each of them. It returns a collection of all VisualGraphObjects which call to matchesFindPattern() returned true.

Returns:
The list of all matching visual graph objects

gatherElements

protected final java.util.Collection gatherElements(VisualGraphObjectContainer vgv)
Looks through all elements in the VisualGraphObjectContainer (recursively) and calls matchesFindPattern() for each of them. It returns a collection of all VisualGraphObjects which call to matchesFindPattern() returned true.

Parameters:
vgv - The container to start looking
Returns:
The list of all matching visual graph objects

getSearchText

protected java.lang.String getSearchText()

Returns the search text.

Returns:
the search text.

setSearchText

protected void setSearchText(java.lang.String searchText)

Stores the text which is going to be search for.

Parameters:
searchText - the text which is going to be search for.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.