/** * Updates the background color of a row in case the corresponding node is currently displaying * search results. * * @param node The node that corresponds to the table row. */ private void calculateBackgroundColor(final INaviViewNode node) { final List<SearchResult> results = m_searcher.getResults(); for (final SearchResult result : results) { if ((result.getObject() instanceof NaviNode) && ((NaviNode) result.getObject()).getRawNode().equals(node)) { setBackground(SEARCH_HIT_BACKGROUND); return; } } }
/** * Fills the search results table model with search results data. * * @param results The search results data. */ private void setResults(final List<SearchResult> results) { final Object[][] data = new Object[results.size()][1]; int counter = 0; for (final SearchResult result : results) { if (result.getObject() instanceof NaviNode) { final NaviNode node = (NaviNode) result.getObject(); final ZyLabelContent labelContent = node.getRealizer().getNodeContent(); final String lineText = labelContent.getLineContent(result.getLine()).getText(); data[counter++][0] = lineText; } else if (result.getObject() instanceof NaviEdge) { final NaviEdge edge = (NaviEdge) result.getObject(); final ZyLabelContent labelContent = edge.getLabelContent(); final String lineText = labelContent.getLineContent(result.getLine()).getText(); data[counter++][0] = lineText; } } m_table.setModel(new CResultsTableModel(data, new String[] {"Result"})); m_resultsLabel.setText(String.format("%d search results", data.length)); }