public List<ItemCell> getCells() { List<ItemCell> cells = decorator.getCells(); if (cells == null) { cells = new ArrayList<ItemCell>(); collectCells(cells); decorator.setCells(cells); } return cells; }
@Override public void dispose() { if (selection != null) { getItemProvider().select(getCell(selection).getItem()); } decorator.dispose(); }
protected void fireSelectionChanged() { SourceSelection selection = getSelection(); ITextSourceListener[] listeners = decorator.getListeners(); for (ITextSourceListener listener : listeners) { listener.selectionChanged(selection); } }
public void setMatches(Match[] matches) { cellToMatches = new HashMap<ItemCell, List<Match>>(); for (Match match : matches) { ItemCell cell = getCell(match); List<Match> list = cellToMatches.get(cell); if (list == null) { list = new ArrayList<Match>(); cellToMatches.put(cell, list); } list.add(match); } decorator.clearStyles(); for (ItemCell cell : cellToMatches.keySet()) { updateCell(cell); } decorator.redraw(); }
public void setMatch(Match match) { ItemCell cell1 = null, cell2 = null; if (selection != null) { cell1 = getCell(selection); selection = null; updateCell(cell1); } selection = match; if (selection != null) { cell2 = getCell(selection); updateCell(cell2); } if (cell1 != null) { decorator.redraw(cell1); } if (cell2 != null && cell2 != cell1) { decorator.redraw(cell2); } }
protected void updateCell(ItemCell cell) { List<StyleRange> list = new ArrayList<StyleRange>(); boolean selectionFound = false; if (cellToMatches != null) { List<Match> matches = cellToMatches.get(cell); if (matches != null) { for (Match match : matches) { boolean sel = match.equals(selection); selectionFound = selectionFound | sel; StyleRange range = createRange(match, sel); list.add(range); } } } if (!selectionFound && selection != null) { ItemCell selCell = (ItemCell) selection.getBlock(); if (selCell.equals(cell)) { list.add(createRange(selection, true)); } } StyleRange[] ranges = list.toArray(new StyleRange[list.size()]); decorator.setStyles(cell, ranges); }
@Override public void removeTextSourceListener(ITextSourceListener listener) { decorator.removeTextSourceListener(listener); }
@Override public boolean isDisposed() { return decorator.isDisposed(); }
@Override public void addTextSourceListener(ITextSourceListener listener) { decorator.addTextSourceListener(listener); }