public boolean doCommand(ILayer targetLayer, SearchCommand searchCommand)
throws PatternSyntaxException {
searchCommand.convertToTargetLayer(targetLayer);
AbstractSearchStrategy searchStrategy = (AbstractSearchStrategy) searchCommand
.getSearchStrategy();
final ILayerListener searchEventListener = searchCommand
.getSearchEventListener();
if (searchEventListener != null) {
selectionLayer.addLayerListener(searchEventListener);
}
try {
PositionCoordinate anchor = selectionLayer.getSelectionAnchor();
if (anchor.columnPosition < 0 || anchor.rowPosition < 0) {
anchor = new PositionCoordinate(selectionLayer, 0, 0);
}
searchStrategy.setContextLayer(targetLayer);
Object dataValueToFind = null;
if ((dataValueToFind = searchCommand.getSearchText()) == null) {
dataValueToFind = selectionLayer.getDataValueByPosition(
anchor.columnPosition, anchor.rowPosition);
}
searchStrategy.setCaseSensitive(searchCommand.isCaseSensitive());
searchStrategy.setWrapSearch(searchCommand.isWrapSearch());
searchStrategy.setWholeWord(searchCommand.isWholeWord());
searchStrategy.setIncremental(searchCommand.isIncremental());
searchStrategy.setRegex(searchCommand.isRegex());
searchStrategy.setIncludeCollapsed(searchCommand
.isIncludeCollapsed());
searchStrategy.setSearchDirection(searchCommand
.getSearchDirection());
searchStrategy.setComparator(searchCommand.getComparator());
searchResultCellCoordinate = searchStrategy
.executeSearch(dataValueToFind);
selectionLayer.fireLayerEvent(new SearchEvent(
searchResultCellCoordinate));
if (searchResultCellCoordinate != null) {