The larger the model, the greater the need to quickly search for elements, for example, all states with a given name resp. name pattern, all occurrences of a certain variable, etc. This section explains how YAKINDU Statechart Tools supports you in finding model elements and quickly navigating to them.
One option, and the most complex one, is to use the search dialog. You can open the dialog using the shortcut
[Ctrl+H] or through selecting
Search → Search... in the main menu.
Doing this will open a dialog with several tabs as shown in the following screenshot:
The tab you want to use is
Statechart Search. If you can not find this tab, you probably disabled this in the past by mistake. You can enable it again by pressing the
Customize... button and selecting
Statechart Search as you can see on the following figure:
Switching to Statechart Search will show you a clean and easily understandable dialog, which can be extended using the Show advanced settings check box for a more professional usage. The possible settings will be described in the following subsection.
Checking the Remember last used page option in the Customize dialog will help you to keep the focus on the Statechart Search tab for further search processes.
The Statechart Search dialog has several options to control your search.
The following table lists the various search options and explains what the search function does if the corresponding checkmark is set.
|Case sensitive||Differentiate between upper-case and lower-case letters in the search string. If this option is not checked, upper-case letters and their corresponding lower-case letters are regarded the same.|
|Regular expression||Interpret the search string as a regular expression. Please note that YAKINDU Statechart Tools supports Java regular expressions, as explained in the java.util.regex.Pattern class API documentation.|
|Search for states/regions||Include states and regions with matching names in the search result.|
|Search for declarations||Include matching declarations in the search result. Declarations are statechart language elements in the definition section, such as variables, events, operations, and named interfaces. The search function will find all occurrences of matching elements.|
|Search for properties||Include elements with matching
properties in the search result. The following items are regarded as properties:
|Scope: workspace||Perform the search operation on all statecharts in the workspace.|
|Scope: selected resources||If a statechart editor has the focus, perform the search operation only on that statechart. If the Project explorer view has the focus, perform the search operation on all statecharts in the selected resources.|
After setting the search options as needed, run the search using the Search button. The search results will be shown in a view called Search.
We will demonstrate the search view using the light switch example from our five-minutes tutorial, using the following settings:
|Search for states/regions||✔|
|Search for declarations||✔|
|Search for properties||✔|
|Scope: Selected resource||✘|
The search view consists of three main components and looks like the following screenshot.
|Searchbar text section||Displays the search string and the number of matches. The latter is updated while the search is running.|
|Toolbar section||See section "Toolbar section"|
|Result section||See section "Result section"|
The toolbar section consists of ten buttons with the following functionalities:
|Redo search||Executes the same search again on the possibly changed model.|
|Cancel searching||Cancels a currently running search. The button is active only if a search run is being executed.|
|History||Use this function to display the search history, to select a formerly-executed search (click on Redo search to actually execute it), or to clear the history.|
|Pin search||Pins the results view. Future search results will be shown in a new search view, instead of rewriting the pinned search view.|
|Collapse all||Collapses the search result tree and displays the root entries only.|
|Expand all||Expands the search result tree and displays all search result entries.|
|Search menu||Contains various search options.|
|Minimize||Minimizes the search view and all its sibling views. A „restore” symbol is shown in a sidebar.|
|Maximize||Maximizes the search view and all its sibling views to the full window size.|
|Restore||Undoes the Maximize function. This button is shown only if the search view is maximized.|
The result section displays the matching statechart elements in a two-column, tree-based view.
You can perform certain actions on the entries in the first column:
|Click on the button||„Closes” the node and collapses all child nodes.|
|Click on the button||„Opens” the node and expands its immediate child nodes.|
|Double-click on a matching element||Navigates to the matching element in the statechart editor, as long a it is not a descendant of an internal or interface element.|
|Double-click on a non-matching path element||Closes an expanded node, opens a collapsed node.|
Another realized search feature is to find references of model elements. You can perform this search on choosing Find references in the context menu of:
This will search for usages of the same element in the local statechart and display them in the search view. Using this method can help you to save time searching for usages of variables, events and operations inside your statechart.
The next section introduces the differences between the first method and this method.
As written in the previous section, Find references is searching for the usages of the exact same model element as selected, whereas in the Search dialog, you have to enter a search string which will find all occurrences of model elements that matched the search string.
Finding occurrences of model elements matching the search string makes it possible to search in different statecharts at the same time, while finding references of a model element is limited to the statechart defining that model element. Depending on your search goals, one method could be more suitable than the other.
To clarify the difference between these methods, different search operations were done using the same model. The used model can be taken from the following figure. It does not have any meaning and is only used for clarification purposes.
|Find references on variable test in the default (unnamed) interface||Finds two matches:
|Find references on variable test in named interface first||Finds one match:
|Find references on state test||Finds one match:
|Search Dialog with the same settings as in section "Search view" and the search string "test"||Finds four matches:
|Search Dialog with the same settings as in section "Search view" and the search string "first.test"||Finds one match:
|Search Dialog with almost the same settings as in section "Search view", but with Search for declarations deactivated, and with the search string "test"||Finds match:
|Search Dialog with almost the same settings as in section "Search view", but with Search for states/regions deactivated, and with the search string "test"||Finds three matches:
As can be seen in this case the search dialog has problems with searching references for the variable test in the unnamed interface.
Open model element is another kind of searching method. It can be used to quickly navigate to states and regions. To access
Open model element, use the shortcut
[Ctrl+Shift+Q] or select
Navigate → Open model element in the main menu.
By doing so, the dialog shown in the next screenshot will open up.
It consists of one input element and two output elements / .
A search operation done with Open model element is equivalent to "Searching via search dialog" with the following setting:
|Search string||same as in|
|Search for States/Regions||✔|
|Search for Declarations||✘|
|Search for Properties||✘|
|Scope: Selected resource||✔|
Differences between Open model element and Search Dialog are slight, but noticeable. The results will promptly appear in while typing your search string in . The hierarchy for the selected result is displayed in as a text instead of using a tree.
Navigating to a result can be done by double clicking the result or pressing
[Enter] on an selected match.
After doing so, the match will be saved. On reopening the dialog, saved model elements that match the new search string will be displayed at the top of unsaved elements making it easier to navigate to them again at a later time.
Saved elements can be removed from history via selecting them and pressing
[Del] or right-click on a saved element and choosing
Remove from history in the context menu.